home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / Aminet / util / moni / Scout-src.lha / src / scout.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-03-09  |  154.2 KB  |  4,480 lines

  1. /**
  2.  * Scout - The Amiga System Monitor
  3.  *
  4.  *------------------------------------------------------------------
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  * You must not use this source code to gain profit of any kind!
  21.  *
  22.  *------------------------------------------------------------------
  23.  *
  24.  * @author Andreas Gelhausen
  25.  * @author Richard Körber <rkoerber@gmx.de>
  26.  */
  27.  
  28.  
  29.  
  30. #include "scout.h"
  31. #include <pragmas/identify_pragmas.h>
  32.  
  33. /*********************************************************************
  34.                            Definitionen
  35. *********************************************************************/
  36. #define MYLIBVERSION    37
  37. #define MUIVERSION      8
  38.  
  39. /*********************************************************************
  40.                          Globale Variablen
  41. *********************************************************************/
  42. extern struct  ExecBase *SysBase;
  43.  
  44. struct Library          *MUIMasterBase;
  45. struct Library          *IdentifyBase;
  46. struct Library          *CxBase;
  47.  
  48. struct Library          *MiscBase;
  49. struct Library          *CiaABase;
  50. struct Library          *CiaBBase;
  51. struct Library          *TimerBase;
  52.  
  53. struct Task             *myprocess;
  54. struct MsgPort          *myarexxport,ScoutPort;
  55. BOOL   ScoutPortAdded = FALSE;
  56.  
  57. struct IOStdReq         InputIORequest;
  58. BOOL   input = TRUE, timer2 = TRUE;
  59. struct timerequest      TimerIORequest;
  60. BYTE   TimerSignal;
  61.  
  62. BOOL   input;
  63. char   *portname;
  64.  
  65. /*
  66. **  MUI
  67. */
  68.  
  69. APTR AP_Scout;
  70.  
  71. APTR WI_Main,WI_About;
  72. APTR WI_Memory,WI_Interrupts,WI_Semaphores;
  73. APTR WI_InputHandler,WI_Residents,WI_Windows,WI_Expansions;
  74. APTR WI_Fonts,WI_Vectors,WI_Mount;
  75. APTR WI_Priority,SL_Priority;
  76. APTR WI_Signal;
  77. APTR WI_LowMemory;
  78. APTR WI_Timer;
  79. APTR WI_Allocations;
  80.  
  81. APTR memlist,intlist;
  82. APTR resilist;
  83. APTR inputlist;
  84. APTR lowmemorylist;
  85. APTR timerlist;
  86.  
  87. APTR memtext,inttext;
  88. APTR resitext;
  89. APTR inputtext;
  90. APTR lowmemorytext;
  91. APTR timertext;
  92. APTR vectext1,vectext2,vectext3,vectext4;
  93. APTR pritext1,pritext2,pritext3;
  94. APTR sigtext1,sigtext2,sigtext3,sigtext4;
  95. APTR alctext1,alctext2,alctext3;
  96.  
  97. APTR resicount,inputcount,intcount,lowmemorycount,timercount;
  98. int  resicnt,inputcnt,intcnt,lowmemorycnt,timercnt;
  99.  
  100. APTR intmoretext0,intmoretext1,intmoretext2,intmoretext3;
  101. APTR resimoretext0,resimoretext1,resimoretext2a,resimoretext2b,resimoretext3;
  102. APTR memmoretext0,memmoretext1,memmoretext2,memmoretext3,memmorelist;
  103.  
  104. APTR BT_Ports,BT_Residents,BT_Interrupts,BT_InputHandler,BT_Tasks,BT_Locks;
  105. APTR BT_Libraries,BT_Devices,BT_Resources,BT_Memory,BT_Windows,BT_Semaphores;
  106. APTR BT_Assigns,BT_Fonts,BT_Expansions,BT_Vectors,BT_Mount,BT_Commands;
  107. APTR BT_System,BT_Commodities,BT_Classes,BT_LowMemory,BT_ScreenMode,BT_Allocations,BT_Timer;
  108.  
  109. APTR BT_AboutContinue;
  110. APTR BT_MemPrint,BT_MemPriority,BT_MemMore,BT_MemExit;
  111. APTR BT_IntUpdate,BT_IntPrint,BT_IntRemove,BT_IntMore,BT_IntExit;
  112. APTR BT_InputUpdate,BT_InputPrint,BT_InputRemove,BT_InputPriority,BT_InputExit;
  113. APTR BT_ResiUpdate,BT_ResiPrint,BT_ResiMore,BT_ResiExit;
  114. APTR BT_VecUpdate,BT_VecPrint,BT_VecExit;
  115. APTR BT_SysPrint,BT_SysExit,BT_SysUpdate;
  116. APTR BT_PriorityOK,BT_PriorityCancel;
  117. APTR BT_SignalOK,BT_SignalCancel;
  118. APTR BT_LowMemoryUpdate,BT_LowMemoryPrint,BT_LowMemoryRemove,BT_LowMemoryPriority,BT_LowMemoryExit;
  119. APTR BT_LowMemoryCause;
  120. APTR BT_TimerUpdate,BT_TimerPrint,BT_TimerRemove,BT_TimerExit;
  121. APTR BT_AlcUpdate,BT_AlcPrint,BT_AlcExit;
  122.  
  123. APTR AboutText;
  124.  
  125. APTR liblist_cmphook_ptr;
  126. APTR devlist_cmphook_ptr;
  127. APTR reslist_cmphook_ptr;
  128. APTR tasklist_cmphook_ptr;
  129. APTR portlist_cmphook_ptr;
  130. APTR comlist_cmphook_ptr;
  131. APTR asslist_cmphook_ptr;
  132. APTR locklist_cmphook_ptr;
  133. APTR cxlist_cmphook_ptr;
  134. APTR classlist_cmphook_ptr;
  135. APTR smodelist_cmphook_ptr;
  136.  
  137. APTR processorvalue, customvalue;
  138. APTR processortext, customtext;
  139.  
  140. #define ID_QUIT  MUIV_Application_ReturnID_Quit
  141.  
  142. struct Remember   *MemRememberKey,*IntRememberKey;
  143. struct Remember   *InputRememberKey,*ResiRememberKey;
  144. struct Remember   *GlobalRememberKey,*LowMemoryRememberKey;
  145. struct Remember   *SysRememberKey,*TimerRememberKey;
  146.  
  147. BPTR     printfile, prevdir;
  148. unsigned char     *tmpstr,*tmpstr2;
  149.  
  150. char *INT_TYPE[] = {
  151.    "TBE (ser.transmit buffer empty)","DSKBLK (disk block complete)",
  152.    "SOFTINT (software interrupt)"   ,"PORTS (external INT2 & CIAA)",
  153.    "COPPER (graphics coprocessor)"  ,"VERTB (vertical blank interval)",
  154.    "BLITTER (blitter finished)"     ,"AUDIO0 (audio channel 0)",
  155.    "AUDIO1 (audio channel 1)"       ,"AUDIO2 (audio channel 2)",
  156.    "AUDIO3 (audio channel 3)"       ,"RBF (ser. receive buffer full)",
  157.    "DSKSYNC (disk sync patt. found)","EXTER (external INT6 & CIAB)",
  158.    "INTEN (special (master enable))","NMI (non-maskable interrupt)"
  159. };
  160.  
  161. char *no_information = "<NO INFORMATION AVAILABLE>";
  162. char *unknown_productid = "<UNKNOWN PRODUCTID>";
  163.  
  164. char UpdateText[]    = "_Update";
  165. char RemoveText[]    = "_Remove";
  166. char CloseText[]     = "_Close";
  167. char PriorityText[]  = "_Priority";
  168. char MoreText[]      = "_More";
  169. char ExitText[]      = "E_xit";
  170. char FreezeText[]    = "_Freeze";
  171. char ActivateText[]  = "_Activate";
  172. char SignalText[]    = "_Signal";
  173. char BreakText[]     = "_Break";
  174. char ContinueText[]  = "_Continue";
  175. char CancelText[]    = "Cancel";
  176. char OKText[]        = "OK";
  177. char ReleaseText[]   = "Re_lease";
  178. char ObtainText[]    = "_Obtain";
  179. char PrintText[]     = "Pr_int";
  180. char ToFrontText[]   = "To _Front";
  181. char AppearText[]    = "_Appear";
  182. char DisappearText[] = "_Disappear";
  183. char EnableText[]    = "_Enable";
  184. char DisableText[]   = "Di_sable";
  185. char KillText[]      = "_Kill";
  186. char ListChgText[]   = "List_Chg";
  187. char UniqueText[]    = "U_nique";
  188. char CauseText[]     = "_Cause";
  189. char FunctionsText[] = "_Functions";
  190.  
  191. char AllocationsText[]  = "Allocations";      /*-*/
  192. char AssignsText[]      = "Assigns";
  193. char ClassesText[]      = "BoopsiClasses";    /*-*/
  194. char CommoditiesText[]  = "Commodities";      /*-*/
  195. char DevicesText[]      = "Devices";
  196. char CommandsText[]     = "Resident Cmds";
  197. char ExpansionsText[]   = "Expansions";
  198. char FontsText[]        = "Fonts";
  199. char InputHandlersText[]= "InputHandlers";
  200. char InterruptsText[]   = "Interrupts";
  201. char LibrariesText[]    = "Libraries";
  202. char LocksText[]        = "Locks";
  203. char LowMemoryText[]    = "LowMemory";        /*-*/
  204. char MemoryText[]       = "Memory";
  205. char MountText[]        = "Mounted Devs";
  206. char PortsText[]        = "Ports";
  207. char ResidentsText[]    = "Residents";
  208. char ResourcesText[]    = "Resources";
  209. char ScreenModeText[]   = "ScreenMode";
  210. char SemaphoresText[]   = "Semaphores";
  211. char SystemText[]       = "System";           /*-*/
  212. char TasksText[]        = "Tasks";
  213. char TimerText[]        = "Timer";            /*-*/
  214. char VectorsText[]      = "Vectors";
  215. char WindowsText[]      = "Windows";
  216.  
  217. #define RB CHECKIT
  218. #define TG CHECKIT|MENUTOGGLE
  219.  
  220. const struct NewMenu menu_list[] =
  221. {
  222.    { NM_TITLE, "Project",  0,0,0,0},
  223.    { NM_ITEM,  "About...", "?",0,0,(APTR) ID_ABOUT},
  224.    { NM_ITEM,  NM_BARLABEL,0,0,0,0},
  225.    { NM_ITEM,  "Quit",     "Q",0,0,(APTR) ID_QUIT},
  226.  
  227.    { NM_TITLE, "List",     0,0,0,0},
  228.    { NM_ITEM,  AllocationsText,  "A",0,0,(APTR) ID_ALLOCATIONS},
  229.    { NM_ITEM,  AssignsText,      "G",0,0,(APTR) ID_ASSIGNS},
  230.    { NM_ITEM,  ClassesText,      "B",0,0,(APTR) ID_CLASSES},
  231.    { NM_ITEM,  CommoditiesText,  "K",0,0,(APTR) ID_COMMODITIES},
  232.    { NM_ITEM,  DevicesText,      "D",0,0,(APTR) ID_DEVICES},
  233.    { NM_ITEM,  ExpansionsText,   "X",0,0,(APTR) ID_EXPANSIONS},
  234.    { NM_ITEM,  FontsText,        "F",0,0,(APTR) ID_FONTS},
  235.    { NM_ITEM,  InputHandlersText,"H",0,0,(APTR) ID_INPUTHANDLER},
  236.    { NM_ITEM,  InterruptsText,   "I",0,0,(APTR) ID_INTERRUPTS},
  237.    { NM_ITEM,  LibrariesText,    "L",0,0,(APTR) ID_LIBRARIES},
  238.    { NM_ITEM,  LocksText,        "O",0,0,(APTR) ID_LOCKS},
  239.    { NM_ITEM,  LowMemoryText,    "J",0,0,(APTR) ID_LOWMEMORY},
  240.    { NM_ITEM,  MemoryText,       "M",0,0,(APTR) ID_MEMORY},
  241.    { NM_ITEM,  MountText,        "N",0,0,(APTR) ID_MOUNT},
  242.    { NM_ITEM,  PortsText,        "P",0,0,(APTR) ID_PORTS},
  243.    { NM_ITEM,  ResidentsText,    "R",0,0,(APTR) ID_RESIDENTS},
  244.    { NM_ITEM,  CommandsText,     "C",0,0,(APTR) ID_COMMANDS},
  245.    { NM_ITEM,  ResourcesText,    "U",0,0,(APTR) ID_RESOURCES},
  246.    { NM_ITEM,  ScreenModeText,   "Z",0,0,(APTR) ID_SCREENMODE},
  247.    { NM_ITEM,  SemaphoresText,   "S",0,0,(APTR) ID_SEMAPHORES},
  248.    { NM_ITEM,  SystemText,       "Y",0,0,(APTR) ID_SYSTEM},
  249.    { NM_ITEM,  TasksText,        "T",0,0,(APTR) ID_TASKS},
  250.    { NM_ITEM,  TimerText,        "E",0,0,(APTR) ID_TIMER},
  251.    { NM_ITEM,  VectorsText,      "V",0,0,(APTR) ID_VECTORS},
  252.    { NM_ITEM,  WindowsText,      "W",0,0,(APTR) ID_WINDOWS},
  253.  
  254.    { NM_TITLE, "Other",          0,0,0,0},
  255.    { NM_ITEM,  "Flush devices",  0,0,0,(APTR) ID_FLUSHDEVS},
  256.    { NM_ITEM,  "Flush fonts",    0,0,0,(APTR) ID_FLUSHFONTS},
  257.    { NM_ITEM,  "Flush libraries",0,0,0,(APTR) ID_FLUSHLIBS},
  258.    { NM_ITEM,  "Flush all",      ".",0,0,(APTR) ID_FLUSHALL},
  259.    { NM_ITEM,  NM_BARLABEL,      0,0,0,0},
  260.    { NM_ITEM,  "Clear reset vectors","!",0,0,(APTR) ID_CLEARRESET},
  261.  
  262.    { NM_END,   NULL,       0,0,0,0},
  263. };
  264.  
  265. /*********************************************************************
  266.                          Requester-Daten
  267. *********************************************************************/
  268. struct EasyStruct myreqES = {
  269.    sizeof (struct EasyStruct),
  270.    0,
  271.    "Scout Request", 
  272.    NULL,
  273.    NULL,
  274. };
  275.  
  276. int MyRequest (char *gadgets, char *fmt, ...) {
  277.    struct   Window   *myreq_window = NULL;
  278.    int      result;
  279.    ULONG    iflags = NULL;
  280.    char     buf[256];
  281.  
  282.    va_list args;
  283.    va_start(args,fmt);
  284.    vsprintf (buf, fmt, args);
  285.  
  286.    get (WI_Main, MUIA_Window_Window, &myreq_window);
  287.  
  288.    myreqES.es_TextFormat = buf;
  289.    myreqES.es_GadgetFormat = gadgets;
  290.    result = EasyRequest (myreq_window, &myreqES, &iflags);
  291.  
  292.    va_end (args);
  293.    return (result);
  294. }
  295.  
  296. char initialdrawer[TEXTLENGTH + 1];
  297. char initialfile[FILENAMELENGTH + 1] = "prt:";
  298. UBYTE *printfilename = NULL;
  299.  
  300. BOOL FileRequest (void) {
  301.    struct   Window         *aslfr_window = NULL;
  302.    struct   FileRequester  *requester;
  303.    BOOL     result = FALSE;
  304.    char     endchar;
  305.  
  306.    get (WI_Main, MUIA_Window_Window, &aslfr_window);
  307.  
  308.    if (aslfr_window) {
  309.       if (requester = AllocAslRequestTags (ASL_FileRequest,
  310.                       ASLFR_Window, aslfr_window,
  311.                       ASLFR_PrivateIDCMP, TRUE,
  312.                       ASLFR_SleepWindow, TRUE,
  313.                       NULL)) {
  314.  
  315.          result = AslRequestTags (requester,
  316.                   ASLFR_TitleText, "Choose file or printer!",
  317.                   ASLFR_InitialDrawer, initialdrawer,
  318.                   ASLFR_InitialFile, initialfile,
  319.                   ASLFR_DoSaveMode, TRUE,
  320.                   NULL);
  321.  
  322.          strncpy (initialdrawer, requester->fr_Drawer, TEXTLENGTH);
  323.          strncpy (initialfile, requester->fr_File, FILENAMELENGTH);
  324.  
  325.          strcpy (printfilename, initialdrawer);
  326.          endchar = printfilename[strlen(printfilename) -1];
  327.  
  328.          if ((strlen(initialdrawer) != 0) && (endchar != '/') && (endchar != ':'))
  329.             strcat (printfilename, "/");
  330.          strcat (printfilename, initialfile);
  331.  
  332.          FreeAslRequest (requester);
  333.       }
  334.    }
  335.    return (result);
  336. }
  337.  
  338. BPTR PrintHandle;
  339. LONG PrintHandleMode = MODE_NEWFILE;
  340.  
  341. BPTR HandlePrintStart (char *filename) {
  342.    PrintHandle = NULL;
  343.  
  344.    if (AP_Scout) {
  345.       if ((! filename) && (! FileRequest()))
  346.          return (NULL);
  347.       ApplicationSleep();
  348.    } else if ((! filename) || (filename[0] == '\0')) {
  349.       return (Output());
  350.    }
  351.    if (filename) {
  352.       printfilename = filename;
  353.    }
  354.    if (! (PrintHandle = Open (printfilename, PrintHandleMode))) {
  355.       if (PrintHandleMode == MODE_OLDFILE) {
  356.          PrintHandle = Open (printfilename, MODE_NEWFILE);
  357.       }
  358.       if (! PrintHandle)
  359.          MyRequest ("Continue", "Couldn't open file \'%ls\'!", printfilename);
  360.    }
  361.    if (PrintHandle) {
  362.       Seek (PrintHandle, NULL, OFFSET_END);
  363.    }
  364.    return (PrintHandle);
  365. }
  366.  
  367. void HandlePrintStop (void) {
  368.    if (AP_Scout) {
  369.       AwakeApplication();
  370.    }
  371.    if (PrintHandle) {
  372.       Close (PrintHandle);
  373.    }
  374. }
  375.  
  376. /*********************************************************************
  377.                            WinFree-Handling
  378.    Die Abkopplung einiger Windows wird hiermit realisiert!
  379. *********************************************************************/
  380. struct WinFree *WinFree_ToDo;
  381. struct WinFlag *WinFlag_ToDo;
  382.  
  383. struct WinFree FirstWinFree = {
  384.    (APTR) NULL, (struct Remember *) NULL,
  385.    &FirstWinFree, &FirstWinFree
  386. };
  387.  
  388. void RemoveWinFree (void) {
  389.    if (SingleDetailWinFree == WinFree_ToDo) {
  390.       SingleDetailWinFree = NULL;
  391.    }
  392.  
  393.    SetWindowClose (WinFree_ToDo->wf_Window,FALSE);
  394.    FreeRemember (&WinFree_ToDo->wf_RememberKey, TRUE);
  395.  
  396.    WinFree_ToDo->wf_Next->wf_Previous = WinFree_ToDo->wf_Previous;
  397.    WinFree_ToDo->wf_Previous->wf_Next = WinFree_ToDo->wf_Next;
  398.  
  399.    FreeMem (WinFree_ToDo, sizeof (struct WinFree));
  400. }
  401.  
  402. struct WinFree *AllocWinFree (void) {
  403.    struct WinFree *result;
  404.  
  405.    if (result = AllocMem (sizeof (struct WinFree), MEMF_ANY|MEMF_CLEAR)) {
  406.       result->wf_Next = &FirstWinFree;
  407.       result->wf_Previous = FirstWinFree.wf_Previous;
  408.       result->wf_Previous->wf_Next = result;
  409.       result->wf_Next->wf_Previous = result;
  410.    }
  411.    return (result);
  412. }
  413.  
  414. void FreeMemoryOfAllWinFrees (void) {
  415.    struct WinFree *lauf = FirstWinFree.wf_Next, *next;
  416.  
  417.    while (lauf != &FirstWinFree) {
  418.       next = lauf->wf_Next;
  419.  
  420.       FreeRemember (&lauf->wf_RememberKey, TRUE);
  421.       FreeMem (lauf, sizeof (struct WinFree));
  422.  
  423.       lauf = next;
  424.    }
  425. }
  426.  
  427. /*********************************************************************
  428.                                  Fail
  429.    Diese Routine wird zum Schluß des Programmes aufgerufen!
  430. *********************************************************************/
  431. static VOID fail1 (VOID) {
  432.    Forbid();
  433.    if (FindPort ("AMITCP")) {
  434.       Permit();
  435.       failtcp();
  436.    } else {
  437.       Permit();
  438.    }
  439.  
  440.    if (ScoutPortAdded)
  441.       RemPort (&ScoutPort);
  442.  
  443.    FreeSignal (TimerSignal);
  444.  
  445.    if (!timer2) {
  446.       AbortIO ((struct IORequest *) &TimerIORequest);
  447.       CloseDevice ((struct IORequest *) &TimerIORequest);
  448.    }
  449.    if (!input) CloseDevice ((struct IORequest *) &InputIORequest);
  450.  
  451.         if (prevdir)
  452.                 CurrentDir (prevdir);
  453.  
  454.    FreeLibraries();
  455.    FreeDevices();
  456.    FreeResources();
  457.  
  458.    FreeTasks();
  459.    FreePorts();
  460.    FreeCommands();
  461.  
  462.    FreeExpansions();
  463.    FreeMemory();
  464.    FreeResidents();
  465.  
  466.    FreeAssigns();
  467.    FreeLocks();
  468.    FreeMounts();
  469.  
  470.    FreeInputHandler();
  471.    FreeInterrupts();
  472.  
  473.    FreeFonts();
  474.    FreeSemaphores();
  475.    FreeWindows();
  476.  
  477.    FreeTimer();
  478.    FreeLowMemory();
  479.    FreeSMode();
  480.    FreeCx();
  481.    FFreeClass();
  482.    FreeSystem();
  483.  
  484.    FreeRemember (&GlobalRememberKey, TRUE);
  485.  
  486.    if (RexxSysBase) CloseLibrary (RexxSysBase);
  487.    if (ExpansionBase) CloseLibrary (ExpansionBase);
  488.    if (IdentifyBase) CloseLibrary (IdentifyBase);
  489.    if (CxBase) CloseLibrary (CxBase);
  490.    if (AslBase) CloseLibrary (AslBase);
  491.    if (DiskfontBase) CloseLibrary (DiskfontBase);
  492.    if (UtilityBase) CloseLibrary (UtilityBase);
  493.    if (IconBase) CloseLibrary (IconBase);
  494.    if (IntuitionBase) CloseLibrary ((struct Library *) IntuitionBase);
  495.    if (GfxBase) CloseLibrary ((struct Library *) GfxBase);
  496. }
  497.  
  498. static VOID fail (VOID) {
  499.    if (cheattask) RemoveCheatTask();
  500.  
  501.    if (AP_Scout) {
  502.       MUI_DisposeObject (AP_Scout);
  503.       AP_Scout = NULL;
  504.    }
  505.    FreeMemoryOfAllWinFrees();
  506.  
  507.    if (MUIMasterBase) CloseLibrary (MUIMasterBase);
  508.  
  509.    fail1();
  510. }
  511.  
  512. struct Library *MyOpenLibrary (char *libname, ULONG version) {
  513.    struct   Library  *libbase;
  514.  
  515.    if (!(libbase = OpenLibrary(libname,version))) {
  516.       aprintf ("Failed to open %ls version %ld!\n", libname, version);
  517.    }
  518.    return (libbase);
  519. }
  520.  
  521. /*********************************************************************
  522.                                  Init
  523.    Diese Routine wird am Beginn des Programmes aufgerufen!
  524. *********************************************************************/
  525. static int init1 (VOID) {
  526.    GfxBase = (struct GfxBase *) OpenLibrary (GRAPHICS_LIBNAME,MYLIBVERSION);
  527.    IntuitionBase = (struct IntuitionBase *) OpenLibrary (INTUITION_LIBNAME,MYLIBVERSION);
  528.    IconBase = OpenLibrary (ICON_LIBNAME,MYLIBVERSION);
  529.    UtilityBase = OpenLibrary (UTILITY_LIBNAME,MYLIBVERSION);
  530.  
  531.    if ((!GfxBase) || (!IntuitionBase) || (!IconBase) || (!UtilityBase))
  532.       return (FALSE);
  533.  
  534.    if (!(AslBase = MyOpenLibrary (ASL_LIBNAME,MYLIBVERSION)))
  535.       return (FALSE);
  536.  
  537.    if (!(DiskfontBase = MyOpenLibrary (DISKFONT_LIBNAME,MYLIBVERSION)))
  538.       return (FALSE);
  539.  
  540.    IdentifyBase = OpenLibrary(IDENTIFY_LIBNAME,IDENTIFYVERSION);
  541.  
  542.    if (!(CxBase = MyOpenLibrary (CX_LIBNAME,MYLIBVERSION)))
  543.       return (FALSE);
  544.  
  545.    if (!(ExpansionBase = MyOpenLibrary (EXPANSION_LIBNAME,MYLIBVERSION)))
  546.       return (FALSE);
  547.  
  548.    if (!(RexxSysBase = MyOpenLibrary (REXXSYS_LIBNAME,0)))
  549.       return (FALSE);
  550.  
  551.    MiscBase = OpenResource("misc.resource");
  552.    CiaABase = OpenResource("ciaa.resource");
  553.    CiaBBase = OpenResource("ciab.resource");
  554.  
  555.    if (tmpstr = AllocRemember (&GlobalRememberKey, MAXTEXTLENGTH * 3 + 3, MEMF_ANY|MEMF_CLEAR)) {
  556.       tmpstr2 = tmpstr + MAXTEXTLENGTH + 1;
  557.       printfilename = tmpstr2 + MAXTEXTLENGTH + 1;
  558.       strcpy (printfilename, "prt:");
  559.    } else {
  560.       return (FALSE);
  561.    }
  562.    myprocess = FindTask (NULL);
  563.    prevdir = CurrentDir (((struct Process *) myprocess)->pr_HomeDir);
  564.  
  565.    if (input = OpenDevice (INPUT_DEVNAME, NULL, (struct IORequest *) &InputIORequest, NULL)) {
  566.       aprintf ("Failed to open %ls!\n", INPUT_DEVNAME);
  567.       return (FALSE);
  568.    }
  569.  
  570.    if (timer2 = OpenDevice (TIMER_DEVNAME, NULL, (struct IORequest *) &TimerIORequest, NULL)) {
  571.       aprintf ("Failed to open %ls!\n", TIMER_DEVNAME);
  572.       return (NULL);
  573.    }
  574.  
  575.    TimerSignal = AllocSignal (-1);
  576.  
  577.    ScoutPort.mp_Node.ln_Name = "scout.reply";
  578.    ScoutPort.mp_Node.ln_Pri = 1;
  579.    ScoutPort.mp_SigTask = myprocess;
  580.    ScoutPort.mp_SigBit = TimerSignal;
  581.  
  582.    AddPort (&ScoutPort);
  583.    ScoutPortAdded = TRUE;
  584.    InputIORequest.io_Message.mn_ReplyPort = &ScoutPort;
  585.    TimerIORequest.tr_node.io_Message.mn_ReplyPort = &ScoutPort;
  586.  
  587.  
  588.    return (TRUE);
  589. }
  590.  
  591. static int init2 (VOID) {
  592.    if (!(MUIMasterBase = MyOpenLibrary (MUIMASTER_LIBNAME,MUIVERSION)))
  593.       return (NULL);
  594.  
  595.    return (TRUE);
  596. }
  597.  
  598. /*********************************************************************
  599.                         Allerlei Funktionen
  600. *********************************************************************/
  601. void reverse (char s[]) {
  602.    int c, i, j;
  603.    for (i = 0, j = strlen(s)-1; i < j; i++, j--) {
  604.       c = s[i];
  605.       s[i] = s[j];
  606.       s[j] = c;
  607.    }
  608. }
  609.  
  610. char * ltob (ULONG n, int len) {
  611.    static char s[34];
  612.    int i;
  613.    i = 0;
  614.  
  615.    do {
  616.       s[i++] = n % 2 + '0';
  617.       n /= 2;
  618.    } while (--len > 0);
  619.    s[i] = '\0';
  620.    reverse (s);
  621.    return ((char *) &s);
  622. }
  623.  
  624. void healstring (char s[]) {
  625.    int i = 0;
  626.  
  627.    while (s[i++] != '\0') {
  628.       if ((s[i] > '\xfe') && (s[i] <= '\x7')) {
  629.          s[i] = '\0';
  630.       } else if ((s[i] > '\x7') && (s[i] <= '\x11')) {
  631.          s[i] = ' ';
  632.       }
  633.    }
  634. }
  635.  
  636. char * nonetest (char s[]) {
  637.    int i = 0;
  638.    char *none = "<none>";
  639.    unsigned char *t = (unsigned char *) s;
  640.  
  641.    if ((s <= (char *) 0x200) || (s[0] == 0))
  642.       return (none);
  643.  
  644.    while (t[i] != 0) {
  645.       if (!(((t[i] > 8) && (t[i] < 128)) || ((t[i] > 159) && (t[i] != 215) && (t[i] != 247) && (t[i] != 255))))
  646.          return (none);
  647.       i++;
  648.    }
  649.    return (s);
  650. }
  651.  
  652. int GetRamPointerCount (struct Library *lib) {
  653.    int   negsize;
  654.    int   count = 0, offset = 0;
  655.    APTR  value;
  656.    char  *adr;
  657.  
  658.    adr = (char *) lib;
  659.    negsize = lib->lib_NegSize;
  660.  
  661.    while (((offset += 6) <= negsize) && *(WORD *)(adr - offset)) {
  662.       if (*(WORD *)(adr - offset) == 0x4ef9) {
  663.          value = (APTR) *(LONG *)(adr - offset + 2);
  664.          if ((points2ram(value)) || (!value))
  665.             count += 1;
  666.       }
  667.    }
  668.  
  669.    if (offset >= negsize) {
  670.       return (count);
  671.    } else {
  672.       return (-1);
  673.    }
  674. }
  675.  
  676. /*********************************************************************
  677.                                Memory
  678. *********************************************************************/
  679. struct   MemoEntry {
  680.    struct   MemoEntry   *mem_next;
  681.    struct   MemHeader   *mem_adr;
  682.    char  mem_address[10];
  683.    char  mem_name[NODENAMELENGTH+2];
  684.    char  mem_type[NODETYPELEN+1];
  685.    char  mem_pri[10];
  686.    char  mem_lower[10];
  687.    char  mem_upper[10];
  688.    char  mem_attributes[10];
  689. };
  690.  
  691. __asm LONG memlist_dspfunc(register __a2 char **array, register __a1 struct MemoEntry *mementry, register __a0 struct Hook *hook) {
  692.    if (mementry) {
  693.       *array++ = mementry->mem_address;
  694.       *array++ = mementry->mem_name;
  695.       *array++ = mementry->mem_type;
  696.       *array++ = mementry->mem_pri;
  697.       *array++ = mementry->mem_lower;
  698.       *array++ = mementry->mem_upper;
  699.       *array++ = mementry->mem_attributes;
  700.       *array   = NULL;
  701.    } else {
  702.       *array++ = ESC "bAddress";
  703.       *array++ = ESC "bln_Name";
  704.       *array++ = ESC "bln_Type";
  705.       *array++ = ESC "bln_Pri";
  706.       *array++ = ESC "bmh_Lower";
  707.       *array++ = ESC "bmh_Upper";
  708.       *array++ = ESC "bmh_Attr";
  709.       *array = NULL;
  710.    }
  711.    return(0);
  712. }
  713.  
  714. struct Hook memlist_dsphook = {
  715.  {NULL, NULL},
  716.  (ULONG (* )())memlist_dspfunc,
  717.  NULL, NULL
  718. };
  719.  
  720. void FreeMemory (void) {
  721.    MyFreeStructs (&MemRememberKey, memtext, memlist);
  722. }
  723.  
  724. int GetMemory (struct MemoEntry **first) {
  725.    struct   MemHeader      *mem;
  726.    struct   MemoEntry      *mementry,*previous = NULL;
  727.  
  728.    int memcnt = 0;
  729.    *first = 0;
  730.  
  731.    mem = FIRSTMEMORY;
  732.  
  733.    if (clientstate) {
  734.       if (SendDaemon ("GetMemList")) {
  735.          while ((mementry = AllocRemember (&MemRememberKey, sizeof (struct MemoEntry), MEMF_ANY|MEMF_CLEAR)) \
  736.            && (ReceiveDecodedEntry ((UBYTE *) mementry, sizeof (struct MemoEntry)))) {
  737.             IsHex (mementry->mem_address, (long *) &mementry->mem_adr);
  738.  
  739.             if (! *first)
  740.                *first = mementry;
  741.             if (previous)
  742.                previous->mem_next = mementry;
  743.  
  744.             memcnt++;
  745.             previous = mementry;
  746.          }
  747.       }
  748.    } else {
  749.       while ((mem->mh_Node.ln_Succ != 0) && (mementry = AllocRemember (&MemRememberKey, sizeof (struct MemoEntry), MEMF_ANY|MEMF_CLEAR))) {
  750.          if (! *first)
  751.             *first = mementry;
  752.          if (previous)
  753.             previous->mem_next = mementry;
  754.  
  755.          mementry->mem_adr = mem;
  756.  
  757.          sprintf (mementry->mem_address, "$%08x", mem);
  758.          strncpy (mementry->mem_name, nonetest (mem->mh_Node.ln_Name), 20);
  759.          strcpy (mementry->mem_type, GetNodeType (mem->mh_Node.ln_Type));
  760.          sprintf (mementry->mem_pri, "%4d ", mem->mh_Node.ln_Pri);
  761.          sprintf (mementry->mem_lower, "$%08x", mem->mh_Lower);
  762.          sprintf (mementry->mem_upper, "$%08x", mem->mh_Upper);
  763.          sprintf (mementry->mem_attributes, " $%04x", mem->mh_Attributes);
  764.          memcnt++;
  765.  
  766.          previous = mementry;
  767.          mem = (struct MemHeader *) mem->mh_Node.ln_Succ;
  768.       }
  769.    }
  770.    return (memcnt);
  771. }
  772.  
  773. void PrintMemory (char *filename) {
  774.    int   i=1;
  775.    BPTR  handle;
  776.    struct MemoEntry *entryp;
  777.  
  778.    handle = HandlePrintStart (filename);
  779.    if ((handle) && (PrintOneLine (handle, "\n  Address  Name                 Type     Pri    Lower     Upper     Attr\n\n"))) {
  780.       if (! WI_Memory) {
  781.          i = GetMemory (&entryp);
  782.       }
  783.       if (i) {
  784.          for (i=0;;i++) {
  785.             if (WI_Memory)
  786.                DoMethod (memlist,MUIM_List_GetEntry,i,&entryp);
  787.             if (!entryp) break;
  788.  
  789.             sprintf (tmpstr2, " %ls %-20.20ls %-8ls%4ls %ls %ls %ls\n", entryp->mem_address, entryp->mem_name, entryp->mem_type, entryp->mem_pri, entryp->mem_lower, entryp->mem_upper, entryp->mem_attributes);
  790.             if (! (PrintOneLine (handle, tmpstr2)))
  791.                break;
  792.  
  793.             if (! WI_Memory)
  794.                entryp = entryp->mem_next;
  795.          }
  796.       }
  797.    }
  798.    HandlePrintStop();
  799. }
  800.  
  801. void ShowMemory (void) {
  802.    struct   MemHeader      *mem;
  803.    struct   MemoEntry      *memo;
  804.  
  805.    mem = FIRSTMEMORY;
  806.  
  807.    ApplicationSleep();
  808.    set (memlist,MUIA_List_Quiet,TRUE);
  809.    set (BT_MemPriority, MUIA_Disabled, TRUE);
  810.    set (BT_MemMore, MUIA_Disabled, TRUE);
  811.  
  812.    FreeMemory();
  813.    GetMemory (&memo);
  814.  
  815.    while (memo) {
  816.       InsertBottomEntry (memlist, (APTR *) &memo);
  817.       memo = memo->mem_next;
  818.    }
  819.  
  820.    AwakeApplication();
  821.    set (memlist,MUIA_List_Quiet,FALSE);
  822. }
  823.  
  824. void SendMemList (void) {
  825.    struct   MemoEntry      *memo;
  826.  
  827.    FreeMemory();
  828.    GetMemory (&memo);
  829.  
  830.    while (memo) {
  831.       SendEncodedEntry ((UBYTE *) memo, sizeof (struct MemoEntry));
  832.       memo = memo->mem_next;
  833.    }
  834.    FreeMemory();
  835. }
  836.  
  837. __asm LONG memmore_dspfunc(register __a2 char **array, register __a1 struct HunkEntry *hunkentry, register __a0 struct Hook *hook) {
  838.    if (hunkentry) {
  839.       *array++ = hunkentry->he_lower;
  840.       *array++ = hunkentry->he_upper;
  841.       *array++ = hunkentry->he_size;
  842.       *array   = NULL;
  843.    } else {
  844.       *array++ = ESC "bStart";
  845.       *array++ = ESC "bEnd";
  846.       *array++ = ESC "bSize";
  847.       *array++ = NULL;
  848.    }
  849.    return (0);
  850. }
  851.  
  852. struct Hook memmore_dsphook = {
  853.  {NULL, NULL},
  854.  (ULONG (* )())memmore_dspfunc,
  855.  NULL, NULL
  856. };
  857.  
  858.  
  859. void GetChunkList (struct MemHeader *mem, struct Remember **remkey) {
  860.    #define mementryanzahl 20
  861.  
  862.    struct   HunkEntry  *hunkentry,*chunkmem;
  863.    struct   MemChunk   *first,*chunk;
  864.    ULONG    size;
  865.    int      count = 0;
  866.  
  867.    set(memmorelist,MUIA_List_Quiet,TRUE);
  868.  
  869.    if (first = mem->mh_First) {
  870.  
  871.       chunk = first;
  872.       while (chunk) {
  873.          count++;
  874.          chunk = chunk->mc_Next;
  875.       }
  876.       count += 10;
  877.  
  878.       if (chunkmem = AllocRemember (remkey, count * sizeof (struct HunkEntry), MEMF_ANY|MEMF_CLEAR)) {
  879.  
  880.          chunk = first;
  881.          hunkentry = chunkmem;
  882.          while ((count) && (chunk)) {
  883.             size = chunk->mc_Bytes;
  884.             sprintf (hunkentry->he_lower, "$%08x", chunk);
  885.             sprintf (hunkentry->he_size, "%8d", size);
  886.             sprintf (hunkentry->he_upper, "$%08x", ((char *) chunk) + size);
  887.  
  888.             InsertBottomEntry (memmorelist, (APTR *) &hunkentry);
  889.  
  890.             hunkentry += 1;
  891.             chunk = chunk->mc_Next;
  892.             count--;
  893.          }
  894.       }
  895.    }
  896.    set(memmorelist,MUIA_List_Quiet,FALSE);
  897. }
  898.  
  899. void GetMemTypeToTmpstr (ULONG attributes) {
  900.    int   i=0;
  901.  
  902.    ULONG memtype[]  = { MEMF_PUBLIC,MEMF_CHIP,MEMF_FAST,
  903.                         MEMF_LOCAL,MEMF_24BITDMA,MEMF_KICK,
  904.                         MEMF_CLEAR,MEMF_LARGEST,MEMF_REVERSE,MEMF_TOTAL,
  905.                         MEMF_ANY };
  906.  
  907.    char  *memtext[] = { "PUBLIC","CHIP","FAST",
  908.                         "LOCAL","24BITDMA","KICK",
  909.                         "CLEAR","LARGEST","REVERSE","TOTAL" };
  910.  
  911.    tmpstr[0] = '\0';
  912.    while (memtype[i]) {
  913.       if (attributes & memtype[i]) {
  914.          if (strlen (tmpstr))
  915.             strcat (tmpstr, ", ");
  916.          strcat (tmpstr, memtext[i]);
  917.       }
  918.       i++;
  919.    }
  920.    if (!attributes)
  921.       strcpy (tmpstr, "ANY");
  922. }
  923.  
  924. void GetMemMore (struct MemHeader *mem) {
  925.    int   total, inuse;
  926.  
  927.    unsigned char     *title = "MEMORY: ";
  928.    struct   WinFree  *ptr;
  929.  
  930.    if (ptr = AllocWinFree()) {
  931.       ptr->wf_Window = (APTR) WindowObject,
  932.  
  933. //      MUIA_Window_SizeGadget, FALSE,
  934.       MUIA_HelpNode, MemoryText,
  935.       MUIA_Window_ID, MakeDetailID('.','M','E','M'),
  936.       WindowContents, HGroup,
  937.          Child, VGroup, MUIA_Group_SameWidth, TRUE,
  938.             Child, MyLabel2 ("Name:"),
  939.             Child, MyLabel2 ("Address:\nPri:\nType:\nFree:\nLargest:"),
  940.             Child, MyLabel2 ("Attributes:"),
  941.             Child, MyLabel2 ("\nChunks:"),
  942.             Child, MyVSpace(0),
  943.          End,
  944.          Child, VGroup, MUIA_Group_SameWidth, TRUE,
  945.             Child, memmoretext0 = MyTextObject(),
  946.             Child, HGroup,
  947.                Child, memmoretext1 = MyTextObject2(),
  948.                Child, MyLabel ("First:\nLower:\nUpper:\nInUse:\nTotal:"),
  949.                Child, memmoretext2 = MyTextObject2(),
  950.             End,
  951.             Child, memmoretext3 = MyTextObject(),
  952.             Child, memmorelist = ListviewObject,
  953.                MUIA_Listview_DoubleClick, TRUE,
  954.                MUIA_Listview_Input, FALSE,
  955.                MUIA_Listview_List, ListObject,
  956.                MUIA_List_Format, "COL=0 DELTA=8,COL=1 DELTA=8,COL=2 P=\33r",
  957. //               MUIA_List_AdjustWidth, TRUE,
  958.                MUIA_List_Title, TRUE,
  959.                MUIA_List_DisplayHook, &memmore_dsphook,
  960.                ReadListFrame,
  961.             End, End,
  962.          End,
  963.       End, End;
  964.  
  965.       total = ((int) mem->mh_Upper) - ((int) mem->mh_Lower);
  966.       inuse = total - ((int) mem->mh_Free);
  967.  
  968.       if (ptr->wf_Window) {
  969.          GetChunkList(mem, &ptr->wf_RememberKey);
  970.  
  971.          MySetContents (memmoretext1, ESC "r$%08x\n" ESC "c%d\n%s\n" ESC "r%d\n%d", mem, mem->mh_Node.ln_Pri, GetNodeType (mem->mh_Node.ln_Type), mem->mh_Free, AvailMem (MEMF_LARGEST | mem->mh_Attributes));
  972.          MySetContents (memmoretext2, ESC "r$%08x\n$%08x\n$%08x\n%d\n%d", mem->mh_First, mem->mh_Lower, mem->mh_Upper, inuse, total);
  973.  
  974.          GetMemTypeToTmpstr ((ULONG) mem->mh_Attributes);
  975.          set (memmoretext3, MUIA_Text_Contents, tmpstr);
  976.  
  977.          HandleWindowOpen (ptr, title, nonetest (mem->mh_Node.ln_Name));
  978.          set (ptr->wf_Window,MUIA_Window_ActiveObject,memmorelist);
  979.          set (memmoretext0, MUIA_Text_Contents, nonetest (mem->mh_Node.ln_Name));
  980.          HandleWindowClose (ptr);
  981.       }
  982.    }
  983. }
  984.  
  985.  
  986. /*********************************************************************
  987.                               Interrupts
  988. *********************************************************************/
  989. struct   IntEntry {
  990.    struct IntEntry *int_next;
  991.    char  *int_adr;
  992.    char  int_address[10];
  993.    char  int_name[NODENAMELENGTH+2];
  994.    char  int_pri[10];
  995.    char  int_data[10];
  996.    char  int_code[20];
  997.    char  int_num[4];
  998.    char  int_kind[10];
  999.    int   int_number;
  1000. };
  1001.  
  1002. __asm LONG intlist_dspfunc(register __a2 char **array, register __a1 struct IntEntry *intentry, register __a0 struct Hook *hook) {
  1003.    if (intentry) {
  1004.       *array++ = intentry->int_address;
  1005.       *array++ = intentry->int_name;
  1006.       *array++ = intentry->int_pri;
  1007.       *array++ = intentry->int_data;
  1008.       *array++ = intentry->int_code;
  1009.       *array++ = intentry->int_num;
  1010.       *array++ = intentry->int_kind;
  1011.       *array   = NULL;
  1012.    } else {
  1013.       *array++ = ESC "bAddress";
  1014.       *array++ = ESC "bln_Name";
  1015.       *array++ = ESC "bln_Pri";
  1016.       *array++ = ESC "bis_Data";
  1017.       *array++ = ESC "bis_Code";
  1018.       *array++ = ESC "bNUM";
  1019.       *array++ = ESC "bIntType";
  1020.       *array++ = NULL;
  1021.    }
  1022.    return(0);
  1023. }
  1024.  
  1025. struct Hook intlist_dsphook = {
  1026.  {NULL, NULL},
  1027.  (ULONG (* )())intlist_dspfunc,
  1028.  NULL, NULL
  1029. };
  1030.  
  1031. void FreeInterrupts (void) {
  1032.    MyFreeStructs (&IntRememberKey, inttext, intlist);
  1033. }
  1034.  
  1035. APTR GetInterrupts (int si_job, char *name, struct IntEntry **first) {
  1036.    struct   IntVector   *intvec;
  1037.    struct   Interrupt   *intr,*intradr;
  1038.    char     *mark;
  1039.    struct   Node        *intnode;
  1040.    struct   IntEntry    *intentry,*previous = NULL;
  1041.    int      i;
  1042.  
  1043.    int intcnt = 0;
  1044.    if (first)
  1045.       *first = 0;
  1046.  
  1047.    IsHex (name, (long *) &intradr);
  1048.  
  1049.    if (clientstate) {
  1050.       if (SendDaemon ("GetIntList")) {
  1051.          while ((intentry = AllocRemember (&IntRememberKey, sizeof (struct IntEntry), MEMF_ANY|MEMF_CLEAR)) \
  1052.            && (ReceiveDecodedEntry ((UBYTE *) intentry, sizeof (struct IntEntry)))) {
  1053.             IsHex (intentry->int_address, (long *) &intentry->int_adr);
  1054.  
  1055.             if (! *first)
  1056.                *first = intentry;
  1057.             if (previous)
  1058.                previous->int_next = intentry;
  1059.  
  1060.             intcnt++;
  1061.             previous = intentry;
  1062.          }
  1063.       }
  1064.    } else {
  1065.       for (i = 0; i <= 15; i++) {
  1066.          if (intvec = (struct IntVector *) &(SysBase->IntVects[i])) {
  1067.             if (intnode = intvec->iv_Node) {
  1068.                if ((si_job == SI_LIST) && (intvec->iv_Code) && (intentry = AllocRemember (&IntRememberKey, sizeof (struct IntEntry), MEMF_ANY|MEMF_CLEAR))) {
  1069.                   if (! *first)
  1070.                      *first = intentry;
  1071.                   if (previous)
  1072.                      previous->int_next = intentry;
  1073.  
  1074.                   intentry->int_adr = (char *) intnode;
  1075.  
  1076.                   if (points2ram((APTR) intvec->iv_Code)) {
  1077.                      sprintf (intentry->int_code, HELL "$%08x", intvec->iv_Code);
  1078.                   } else {
  1079.                      sprintf (intentry->int_code, "$%08x", intvec->iv_Code);
  1080.                   }
  1081.                   sprintf (intentry->int_address, "$%08x", intnode);
  1082.                   strncpy (intentry->int_name, nonetest (intnode->ln_Name), 26);
  1083.                   sprintf (intentry->int_pri, "%4d ", intnode->ln_Pri);
  1084.                   sprintf (intentry->int_data, "$%08x", intvec->iv_Data);
  1085.                   sprintf (intentry->int_num, "%2d ", i);
  1086.                   strcpy (intentry->int_kind, "Handler");
  1087.  
  1088.                   intcnt++;
  1089.                   previous = intentry;
  1090.                } else if ((si_job == SI_FIND) && (! stricmp (name, intnode->ln_Name))) {
  1091.                   return ((APTR) intnode);
  1092.                } else if ((si_job == SI_REMOVE) && (! stricmp (name, intnode->ln_Name))) {
  1093.                   return (NULL);
  1094.                }
  1095.                if (intvec = (struct IntVector *) intnode->ln_Succ) {
  1096.                   intnode = intvec->iv_Node;
  1097.                }
  1098.             } else if ((mark = (char *) intvec->iv_Data) && (mark != (char *) -1)) {
  1099.                intr = (struct Interrupt *) ((struct Interrupt *) mark)->is_Node.ln_Succ;
  1100.                mark += 4;
  1101.  
  1102.                while ((intr) && (intr != (struct Interrupt *) mark)) {
  1103.                   if ((si_job == SI_LIST) && (intentry = AllocRemember (&IntRememberKey, sizeof (struct IntEntry), MEMF_ANY|MEMF_CLEAR))) {
  1104.                      if (! *first)
  1105.                         *first = intentry;
  1106.                      if (previous)
  1107.                         previous->int_next = intentry;
  1108.  
  1109.                      intentry->int_adr = (char *) intr;
  1110.  
  1111.                      if (points2ram((APTR) intr->is_Code)) {
  1112.                         sprintf (intentry->int_code, HELL "$%08x", intr->is_Code);
  1113.                      } else {
  1114.                         sprintf (intentry->int_code, "$%08x", intr->is_Code);
  1115.                      }
  1116.                      sprintf (intentry->int_address, "$%08x", intr);
  1117.                      strncpy (intentry->int_name, nonetest (intr->is_Node.ln_Name), 26);
  1118.                      sprintf (intentry->int_pri, "%4d ", intr->is_Node.ln_Pri);
  1119.                      sprintf (intentry->int_data, "$%08x", intr->is_Data);
  1120.                      sprintf (intentry->int_num, "%2d ", i);
  1121.                      strcpy (intentry->int_kind, "Server");
  1122.  
  1123.                      intcnt++;
  1124.                      previous = intentry;
  1125.                   } else if ((si_job == SI_FIND) && (! stricmp (name, intr->is_Node.ln_Name))) {
  1126.                      return ((APTR) intr);
  1127.                   } else if ((si_job == SI_REMOVE) && (! stricmp (name, intr->is_Node.ln_Name))) {
  1128.                      RemIntServer (i, intr);
  1129.                      return ((APTR) intr);
  1130.                   }
  1131.                   intr = (struct Interrupt *) intr->is_Node.ln_Succ;
  1132.                }
  1133.             }
  1134.          }
  1135.       }
  1136.    }
  1137.    if (si_job == SI_LIST) {
  1138.       return ((APTR) intcnt);
  1139.    }
  1140.    return (NULL);
  1141. }
  1142.  
  1143. void PrintInterrupts (char *filename) {
  1144.    int   i=1;
  1145.    BPTR  handle;
  1146.    struct IntEntry *entryp;
  1147.  
  1148.    handle = HandlePrintStart (filename);
  1149.    if ((handle) && (PrintOneLine (handle, "\n  Address   Pri   Data      Code    NUM IntType Name\n\n"))) {
  1150.       if (! WI_Interrupts) {
  1151.          i = (int) GetInterrupts (SI_LIST, NULL, &entryp);
  1152.       }
  1153.       if (i) {
  1154.          for (i=0;;i++) {
  1155.             if (WI_Interrupts)
  1156.                DoMethod (intlist,MUIM_List_GetEntry,i,&entryp);
  1157.             if (!entryp) break;
  1158.  
  1159.             if (entryp->int_code[0] != '$')
  1160.                strcpy (tmpstr, entryp->int_code+2);
  1161.             else
  1162.                strcpy (tmpstr, entryp->int_code);
  1163.    
  1164.             sprintf (tmpstr2, " %ls %ls%ls %ls  %ls%-7.7ls %ls\n", entryp->int_address, entryp->int_pri, entryp->int_data, tmpstr, entryp->int_num, entryp->int_kind, entryp->int_name);
  1165.             if (! (PrintOneLine (handle, tmpstr2)))
  1166.                break;
  1167.  
  1168.             if (! WI_Interrupts)
  1169.                entryp = entryp->int_next;
  1170.          }
  1171.       }
  1172.    }
  1173.    HandlePrintStop();
  1174. }
  1175.  
  1176. void ShowInterrupts (void) {
  1177.    struct IntEntry *intr;
  1178.  
  1179.    ApplicationSleep();
  1180.    set (intlist,MUIA_List_Quiet,TRUE);
  1181.    set (BT_IntRemove, MUIA_Disabled, TRUE);
  1182.    set (BT_IntMore, MUIA_Disabled, TRUE);
  1183.  
  1184.    FreeInterrupts();
  1185.    intcnt = (int) GetInterrupts (SI_LIST, NULL, &intr);
  1186.  
  1187.    while (intr) {
  1188.       InsertBottomEntry (intlist, (APTR *) &intr);
  1189.       intr = intr->int_next;
  1190.    }
  1191.  
  1192.    SetCountText (intcount, intcnt);
  1193.    AwakeApplication();
  1194.    set (intlist,MUIA_List_Quiet,FALSE);
  1195. }
  1196.  
  1197. void SendIntList (void) {
  1198.    struct IntEntry *intr;
  1199.  
  1200.    FreeInterrupts();
  1201.    intcnt = (int) GetInterrupts (SI_LIST, NULL, &intr);
  1202.  
  1203.    while (intr) {
  1204.       SendEncodedEntry ((UBYTE *) intr, sizeof (struct IntEntry));
  1205.       intr = intr->int_next;
  1206.    }
  1207.    FreeInterrupts();
  1208. }
  1209.  
  1210. void GetIntMore (struct IntEntry *intr) {
  1211.    unsigned char     *title = "INTERRUPT: ";
  1212.    struct   WinFree  *ptr;
  1213.  
  1214.    if (ptr = AllocWinFree()) {
  1215.       ptr->wf_Window = (APTR) WindowObject,
  1216.  
  1217. //      MUIA_Window_SizeGadget, FALSE,
  1218.       MUIA_HelpNode, InterruptsText,
  1219.       MUIA_Window_ID, MakeDetailID('.','I','N','T'),
  1220.       WindowContents, HGroup,
  1221.          Child, VGroup, MUIA_Group_SameWidth, TRUE,
  1222.             Child, MyLabel2 ("Name:"),
  1223.             Child, MyLabel2 ("Address:\nPri:\nType:"),
  1224.             Child, MyLabel2 ("IntName:"),
  1225.          End,
  1226.          Child, VGroup, MUIA_Group_SameWidth, TRUE,
  1227.             Child, intmoretext0 = MyTextObject(),
  1228.             Child, HGroup,
  1229.                Child, intmoretext1 = MyTextObject2(),
  1230.                Child, MyLabel ("Data:\nCode:\nIntType:"),
  1231.                Child, intmoretext2 = MyTextObject2(),
  1232.             End,
  1233.             Child, intmoretext3 = MyTextObject(),
  1234.          End,
  1235.       End, End;
  1236.  
  1237.       if (ptr->wf_Window) {
  1238.          MySetContents (intmoretext1, ESC "r%s\n" ESC "c%d\n" ESC "c%s", intr->int_address, ((struct Node *) intr->int_adr)->ln_Pri, GetNodeType (((struct Node *) intr->int_adr)->ln_Type));
  1239.          MySetContents (intmoretext2, ESC "r%s\n%s\n" DUNKEL ESC "c%s", intr->int_data, intr->int_code, intr->int_kind);
  1240.          MySetContents (intmoretext3, INT_TYPE[atoi(intr->int_num)]);
  1241.  
  1242.          HandleWindowOpen (ptr, title, intr->int_name);
  1243.          MySetContents (intmoretext0, intr->int_name);
  1244.          HandleWindowClose (ptr);
  1245.       }
  1246.    }
  1247. }
  1248.  
  1249.  
  1250. /*********************************************************************
  1251.                              InputHandler
  1252. *********************************************************************/
  1253. struct   InputEntry {
  1254.    struct InputEntry *input_next;
  1255.    struct Interrupt  *input_adr;
  1256.    char  input_address[10];
  1257.    char  input_name[NODENAMELENGTH+2];
  1258.    char  input_type[NODETYPELEN+1];
  1259.    char  input_pri[10];
  1260.    char  input_data[10];
  1261.    char  input_code[20];
  1262. };
  1263.  
  1264. __asm LONG inputlist_dspfunc(register __a2 char **array, register __a1 struct InputEntry *inputentry, register __a0 struct Hook *hook) {
  1265.    if (inputentry) {
  1266.       *array++ = inputentry->input_address;
  1267.       *array++ = inputentry->input_name;
  1268.       *array++ = inputentry->input_type;
  1269.       *array++ = inputentry->input_pri;
  1270.       *array++ = inputentry->input_data;
  1271.       *array++ = inputentry->input_code;
  1272.       *array   = NULL;
  1273.    } else {
  1274.       *array++ = ESC "bAddress";
  1275.       *array++ = ESC "bln_Name";
  1276.       *array++ = ESC "bln_Type";
  1277.       *array++ = ESC "bln_Pri";
  1278.       *array++ = ESC "bis_Data";
  1279.       *array++ = ESC "bis_Code";
  1280.       *array++ = NULL;
  1281.    }
  1282.    return(0);
  1283. }
  1284.  
  1285. struct Hook inputlist_dsphook = {
  1286.  {NULL, NULL},
  1287.  (ULONG (* )())inputlist_dspfunc,
  1288.  NULL, NULL
  1289. };
  1290.  
  1291. void FreeInputHandler (void) {
  1292.    MyFreeStructs (&InputRememberKey, inputtext, inputlist);
  1293. }
  1294.  
  1295. int GetInputHandler (struct InputEntry **first) {
  1296.    struct   Interrupt      *intr;
  1297.    struct   Device         *input;
  1298.    struct   InputEntry     *inputentry,*previous = NULL;
  1299.    char     *tmp;
  1300.    char     code[FILENAMELENGTH + 1];
  1301.  
  1302.    int inputcnt = 0;
  1303.    *first = 0;
  1304.  
  1305.    if (clientstate) {
  1306.       if (SendDaemon ("GetInputList")) {
  1307.          while ((inputentry = AllocRemember (&InputRememberKey, sizeof (struct InputEntry), MEMF_ANY|MEMF_CLEAR)) \
  1308.            && (ReceiveDecodedEntry ((UBYTE *) inputentry, sizeof (struct InputEntry)))) {
  1309.             IsHex (inputentry->input_address, (long *) &inputentry->input_adr);
  1310.  
  1311.             if (! *first)
  1312.                *first = inputentry;
  1313.             if (previous)
  1314.                previous->input_next = inputentry;
  1315.  
  1316.             inputcnt++;
  1317.             previous = inputentry;
  1318.          }
  1319.       }
  1320.    } else {
  1321.       if (input = (struct Device *) FindName (&SysBase->DeviceList, INPUT_DEVNAME)) {
  1322.          tmp = (APTR) input;
  1323.          tmp += 148;    /* Mir unbekannter Offsetname! */
  1324.          if (intr = (struct Interrupt *) ((struct Interrupt *) tmp)->is_Node.ln_Succ) {
  1325.             if (intr = (struct Interrupt *) intr->is_Node.ln_Succ) {
  1326.                while ((intr->is_Node.ln_Succ != 0) && (inputentry = AllocRemember (&InputRememberKey, sizeof (struct InputEntry), MEMF_ANY|MEMF_CLEAR))) {
  1327.                   if (! *first)
  1328.                      *first = inputentry;
  1329.                   if (previous)
  1330.                      previous->input_next = inputentry;
  1331.  
  1332.                   inputentry->input_adr = intr;
  1333.  
  1334.                   code[0] = '\0';
  1335.                   if (points2ram((APTR) intr->is_Code)) {
  1336.                      sprintf (code, HELL "$%08x" DUNKEL, intr->is_Code);
  1337.                   } else {
  1338.                      sprintf (code, "$%08x", intr->is_Code);
  1339.                   }
  1340.                   sprintf (inputentry->input_address, "$%08x", intr);
  1341.                   strncpy (inputentry->input_name, nonetest (intr->is_Node.ln_Name), 27);
  1342.                   strcpy (inputentry->input_type, GetNodeType (intr->is_Node.ln_Type));
  1343.                   sprintf (inputentry->input_pri, "%4d ", intr->is_Node.ln_Pri);
  1344.                   sprintf (inputentry->input_data, "$%08x", intr->is_Data);
  1345.                   strcpy (inputentry->input_code, code); 
  1346.                   inputcnt++;
  1347.  
  1348.                   previous = inputentry;
  1349.                   intr = (struct Interrupt *) intr->is_Node.ln_Succ;
  1350.                }
  1351.             }
  1352.          }
  1353.       }
  1354.    }
  1355.    return (inputcnt);
  1356. }
  1357.  
  1358. void PrintInputHandlers (char *filename) {
  1359.    int   i=1;
  1360.    BPTR  handle;
  1361.    struct InputEntry *entryp;
  1362.  
  1363.    handle = HandlePrintStart (filename);
  1364.    if ((handle) && (PrintOneLine (handle, "\n  Address  Type       Pri    Data       Code     Name\n\n"))) {
  1365.       if (! WI_InputHandler) {
  1366.          i = GetInputHandler (&entryp);
  1367.       }
  1368.       if (i) {
  1369.          for (i=0;;i++) {
  1370.             if (WI_InputHandler)
  1371.                DoMethod (inputlist,MUIM_List_GetEntry,i,&entryp);
  1372.             if (!entryp) break;
  1373.  
  1374.             if (points2ram ((APTR) (entryp->input_adr->is_Code)))
  1375.                strcpy (tmpstr, entryp->input_code+2);
  1376.             else
  1377.                strcpy (tmpstr, entryp->input_code);
  1378.    
  1379.             sprintf (tmpstr2, " %ls %-9ls %4ls %ls %-9.9ls %ls\n", entryp->input_address, entryp->input_type, entryp->input_pri, entryp->input_data, tmpstr, entryp->input_name);
  1380.             if (! (PrintOneLine (handle, tmpstr2)))
  1381.                break;
  1382.  
  1383.             if (! WI_InputHandler)
  1384.                entryp = entryp->input_next;
  1385.          }
  1386.       }
  1387.    }
  1388.    HandlePrintStop();
  1389. }
  1390.  
  1391. void ShowInputHandler (void) {
  1392.    struct InputEntry *input;
  1393.  
  1394.    ApplicationSleep();
  1395.    set (inputlist,MUIA_List_Quiet,TRUE);
  1396.    set (BT_InputRemove, MUIA_Disabled, TRUE);
  1397.    set (BT_InputPriority, MUIA_Disabled, TRUE);
  1398.  
  1399.    FreeInputHandler();
  1400.    inputcnt = GetInputHandler (&input);
  1401.  
  1402.    while (input) {
  1403.       InsertBottomEntry (inputlist, (APTR *) &input);
  1404.       input = input->input_next;
  1405.    }
  1406.  
  1407.    SetCountText (inputcount, inputcnt);
  1408.    AwakeApplication();
  1409.    set (inputlist,MUIA_List_Quiet,FALSE);
  1410. }
  1411.  
  1412. void SendInputList (void) {
  1413.    struct InputEntry *input;
  1414.  
  1415.    FreeInputHandler();
  1416.    inputcnt = GetInputHandler (&input);
  1417.  
  1418.    while (input) {
  1419.       SendEncodedEntry ((UBYTE *) input, sizeof (struct InputEntry));
  1420.       input = input->input_next;
  1421.    }
  1422.    FreeInputHandler();
  1423. }
  1424.  
  1425. /*********************************************************************
  1426.                               Residents
  1427. *********************************************************************/
  1428. struct   ResiEntry {
  1429.    struct ResiEntry  *rt_next;
  1430.    struct Resident   *rt_adr;
  1431.    char  rt_address[16];
  1432.    char  rt_name[NODENAMELENGTH+2];
  1433.    char  rt_pri[10];
  1434.    char  rt_idstring[TEXTLENGTH+1];
  1435. };
  1436.  
  1437. __asm LONG resilist_dspfunc(register __a2 char **array, register __a1 struct ResiEntry *resientry, register __a0 struct Hook *hook) {
  1438.    if (resientry) {
  1439.       *array++ = resientry->rt_address;
  1440.       *array++ = resientry->rt_name;
  1441.       *array++ = resientry->rt_pri;
  1442.       *array++ = resientry->rt_idstring;
  1443.       *array   = NULL;
  1444.    } else {
  1445.       *array++ = ESC "bAddress";
  1446.       *array++ = ESC "bln_Name";
  1447.       *array++ = ESC "brt_Pri";
  1448.       *array++ = ESC "brt_IdString";
  1449.       *array++ = NULL;
  1450.    }
  1451.    return(0);
  1452. }
  1453.  
  1454. struct Hook resilist_dsphook = {
  1455.  {NULL, NULL},
  1456.  (ULONG (* )())resilist_dspfunc,
  1457.  NULL, NULL
  1458. };
  1459.  
  1460. void FreeResidents (void) {
  1461.    MyFreeStructs (&ResiRememberKey, resitext, resilist);
  1462. }
  1463.  
  1464. int GetResidents (struct ResiEntry **first) {
  1465.    LONG     *resip, resi;
  1466.    struct   ResiEntry    *resientry,*previous = NULL;
  1467.    struct   ShortList {
  1468.       struct   Resident    *sl_Resident;
  1469.       struct   ShortList   *sl_Next;
  1470.    };
  1471.    struct   ShortList   *sl_Actual;
  1472.  
  1473.    int resicnt = 0;
  1474.    *first = 0;
  1475.  
  1476.    sl_Actual = (struct ShortList *) SysBase->KickTagPtr;
  1477.  
  1478.    if (clientstate) {
  1479.       if (SendDaemon ("GetResiList")) {
  1480.          while ((resientry = AllocRemember (&ResiRememberKey, sizeof (struct ResiEntry), MEMF_ANY|MEMF_CLEAR)) \
  1481.            && (ReceiveDecodedEntry ((UBYTE *) resientry, sizeof (struct ResiEntry)))) {
  1482.             IsHex (resientry->rt_address, (long *) &resientry->rt_adr);
  1483.  
  1484.             if (! *first)
  1485.                *first = resientry;
  1486.             if (previous)
  1487.                previous->rt_next = resientry;
  1488.  
  1489.             resicnt++;
  1490.             previous = resientry;
  1491.          }
  1492.       }
  1493.    } else {
  1494.       while ((sl_Actual) && (sl_Actual->sl_Resident) && (resientry = AllocRemember (&ResiRememberKey, sizeof (struct ResiEntry), MEMF_ANY|MEMF_CLEAR))) {
  1495.          if (! *first)
  1496.             *first = resientry;
  1497.          if (previous)
  1498.             previous->rt_next = resientry;
  1499.  
  1500.          resientry->rt_adr = sl_Actual->sl_Resident;
  1501.  
  1502.          sprintf (resientry->rt_address, HELL "$%08x" DUNKEL, sl_Actual->sl_Resident);
  1503.          strncpy (resientry->rt_name, nonetest (sl_Actual->sl_Resident->rt_Name), NODENAMELENGTH);
  1504.          sprintf (resientry->rt_pri, "%4d", sl_Actual->sl_Resident->rt_Pri);
  1505.          strncpy (resientry->rt_idstring, nonetest (sl_Actual->sl_Resident->rt_IdString), TEXTLENGTH);
  1506.  
  1507.          healstring (resientry->rt_name);
  1508.          healstring (resientry->rt_idstring);
  1509.          resicnt++;
  1510.  
  1511.          previous = resientry;
  1512.          sl_Actual = (struct ShortList *) (0x7fffffff & (ULONG) sl_Actual->sl_Next);
  1513.       }
  1514.  
  1515.       resip = (LONG *) FIRSTRESIDENT;
  1516.  
  1517.       while ((resi = *resip) && (resientry = AllocRemember (&ResiRememberKey, sizeof (struct ResiEntry), MEMF_ANY|MEMF_CLEAR))) {
  1518.          if (! *first)
  1519.             *first = resientry;
  1520.          if (previous)
  1521.             previous->rt_next = resientry;
  1522.  
  1523.          if (0x80000000 & resi) {
  1524.             resip = (long *) (0x7fffffff & resi);
  1525.             resi = *resip;
  1526.          }
  1527.          resientry->rt_adr = (struct Resident *) resi;
  1528.          sprintf (resientry->rt_address, "$%08x", resi);
  1529.          strncpy (resientry->rt_name, nonetest (((struct Resident *) resi)->rt_Name), NODENAMELENGTH);
  1530.          sprintf (resientry->rt_pri, "%4d", ((struct Resident *) resi)->rt_Pri);
  1531.          strncpy (resientry->rt_idstring, nonetest (((struct Resident *) resi)->rt_IdString), TEXTLENGTH);
  1532.  
  1533.          healstring (resientry->rt_name);
  1534.          healstring (resientry->rt_idstring);
  1535.          resicnt++;
  1536.  
  1537.          previous = resientry;
  1538.          resip += 1; /* plus 4 Bytes */
  1539.       }
  1540.    }
  1541.    return (resicnt);
  1542. }
  1543.  
  1544. void PrintResidents (char *filename) {
  1545.    int   i=1;
  1546.    BPTR  handle;
  1547.    struct ResiEntry *entryp;
  1548.  
  1549.    handle = HandlePrintStart (filename);
  1550.    if ((handle) && (PrintOneLine (handle, "\n  Address  Name                     Pri IdString\n\n"))) {
  1551.       if (! WI_Residents) {
  1552.          i = GetResidents (&entryp);
  1553.       }
  1554.       if (i) {
  1555.          for (i=0;;i++) {
  1556.             if (WI_Residents)
  1557.                DoMethod (resilist,MUIM_List_GetEntry,i,&entryp);
  1558.             if (!entryp) break;
  1559.  
  1560.             sprintf (tmpstr2, " $%08lx %-23.23ls %4ls %ls\n", entryp->rt_adr, entryp->rt_name, entryp->rt_pri, entryp->rt_idstring);
  1561.             if (! (PrintOneLine (handle, tmpstr2)))
  1562.                break;
  1563.  
  1564.             if (! WI_Residents)
  1565.                entryp = entryp->rt_next;
  1566.          }
  1567.       }
  1568.    }
  1569.    HandlePrintStop();
  1570. }
  1571.  
  1572. void ShowResidents (void) {
  1573.    struct ResiEntry *resi;
  1574.  
  1575.    ApplicationSleep();
  1576.    set (resilist,MUIA_List_Quiet,TRUE);
  1577.    set (BT_ResiMore, MUIA_Disabled, TRUE);
  1578.  
  1579.    FreeResidents();
  1580.    resicnt = GetResidents (&resi);
  1581.  
  1582.    while (resi) {
  1583.       InsertBottomEntry (resilist, (APTR *) &resi);
  1584.       resi = resi->rt_next;
  1585.    }
  1586.  
  1587.    SetCountText (resicount, resicnt);
  1588.    AwakeApplication();
  1589.    set (resilist,MUIA_List_Quiet,FALSE);
  1590. }
  1591.  
  1592. void SendResiList (void) {
  1593.    struct   ResiEntry   *resi;
  1594.  
  1595.    FreeResidents();
  1596.    resicnt = GetResidents (&resi);
  1597.  
  1598.    while (resi) {
  1599.       SendEncodedEntry ((UBYTE *) resi, sizeof (struct ResiEntry));
  1600.       resi = resi->rt_next;
  1601.    }
  1602.    FreeResidents();
  1603. }
  1604.  
  1605. void GetResiMore (struct Resident *resi) {
  1606.    unsigned char     *title = "RESIDENT: ";
  1607.    struct   WinFree  *ptr;
  1608.  
  1609.    if (ptr = AllocWinFree()) {
  1610.       ptr->wf_Window = (APTR) WindowObject,
  1611.  
  1612. //      MUIA_Window_SizeGadget, FALSE,
  1613.       MUIA_HelpNode, ResidentsText,
  1614.       MUIA_Window_ID, MakeDetailID('.','R','E','S'),
  1615.       WindowContents, HGroup,
  1616.          Child, VGroup, MUIA_Group_SameWidth, TRUE,
  1617.             Child, MyLabel2 ("Name:"),
  1618.             Child, MyLabel2 ("Address:\nPri:\nType:\nVersion:"),
  1619.             Child, MyLabel2 ("IdString:"),
  1620.          End,
  1621.          Child, VGroup, MUIA_Group_SameWidth, TRUE,
  1622.             Child, resimoretext0 = MyTextObject(),
  1623.             Child, HGroup,
  1624.                Child, resimoretext1 = MyTextObject(),
  1625.                Child, VGroup,
  1626.                   Child, MyLabel ("EndSkip:\nInit:"),
  1627.                   Child, MyLabel ("Flags:"),
  1628.                End,
  1629.                Child, VGroup, MUIA_Group_SameWidth, TRUE,
  1630.                   Child, resimoretext2a = MyTextObject(),
  1631.                   Child, resimoretext2b = KeyButtonF ('b', resi->rt_Flags),
  1632.                End,
  1633.             End,
  1634.             Child, resimoretext3 = MyTextObject(),
  1635.          End,
  1636.       End, End;
  1637.  
  1638.       if (ptr->wf_Window) {
  1639.          MySetContents (resimoretext1, ESC "c$%08x\n%d\n%s\n%d", resi, resi->rt_Pri, GetNodeType (resi->rt_Type), resi->rt_Version);
  1640.          MySetContents (resimoretext2a, ESC "c$%08x\n$%08x", resi->rt_EndSkip, resi->rt_Init);
  1641.  
  1642.          HandleFlagsButtonPressed (resimoretext2b, ptr, "(RESIDENT)", "rt_Flags", resi->rt_Flags, (struct LongFlag *) &rtf_flags, NULL, 'b');
  1643.          HandleWindowOpen (ptr, title, resi->rt_Name);
  1644.          MySetContentsHealed (resimoretext0, resi->rt_Name);
  1645.          MySetContentsHealed (resimoretext3, nonetest (resi->rt_IdString));
  1646.          HandleWindowClose (ptr);
  1647.       }
  1648.    }
  1649. }
  1650.  
  1651.  
  1652. /*********************************************************************
  1653.                                Vectors
  1654. *********************************************************************/
  1655. void ClearResetVectors (void) {
  1656.    SysBase->ColdCapture = NULL;
  1657.    SysBase->CoolCapture = NULL;
  1658.    SysBase->WarmCapture = NULL;
  1659.    SysBase->KickMemPtr = NULL;
  1660.    SysBase->KickTagPtr = NULL;
  1661.    SysBase->KickCheckSum = NULL;
  1662. }
  1663.  
  1664. void PrintVectors (char *filename) {
  1665.    char  *VBR;
  1666.    BPTR  handle;
  1667.  
  1668.    VBR = (char *) GetVBR ();
  1669.  
  1670.    handle = HandlePrintStart (filename);
  1671.    if (handle) {
  1672.       if (clientstate) {
  1673.          char  tmpbuffer[256];
  1674.  
  1675.          if (SendDaemon ("Vectors")) {
  1676.             while ((sgets (client_socket, tmpbuffer, 256)) \
  1677.               && (strcmp (tmpbuffer, CMD_DONE)) \
  1678.               && (strcmp (tmpbuffer, CMD_ERROR))) {
  1679.                PrintOneLine (handle, tmpbuffer);
  1680.             }
  1681.          }
  1682.       } else {
  1683.          if (PrintOneLine (handle, "\nReset Vectors:\n\n")) {
  1684.             sprintf (tmpstr2, " %18ls $%08lx %18ls $%08lx\n %18ls $%08lx %18ls $%08lx\n %18ls $%08lx %18ls $%08lx\n", "ColdCapture:",SysBase->ColdCapture,"KickMemPtr:",SysBase->KickMemPtr,"CoolCapture:",SysBase->CoolCapture,"KickTagPtr:",SysBase->KickTagPtr,"WarmCapture:",SysBase->WarmCapture,"KickCheckSum:",SysBase->KickCheckSum);
  1685.             PrintOneLine (handle, tmpstr2);
  1686.  
  1687.             PrintOneLine (handle, "\nAuto Vector Interrupts:\n\n");
  1688.  
  1689.             sprintf (tmpstr2, " %18ls $%08lx %18ls $%08lx\n %18ls $%08lx %18ls $%08lx\n %18ls $%08lx %18ls $%08lx\n %18ls $%08lx\n", "Level1 ($0064):",*((ULONG *) (VBR + 0x0064)),"Level5 ($0074):",*((ULONG *) (VBR + 0x0074)),"Level2 ($0068):",*((ULONG *) (VBR + 0x0068)),"Level6 ($0078):",*((ULONG *) (VBR + 0x0078)),"Level3 ($006c):",*((ULONG *) (VBR + 0x006c)),"Level7 ($007c):",*((ULONG *) (VBR + 0x007c)),"Level4 ($0070):",*((ULONG *) (VBR + 0x0070)));
  1690.             PrintOneLine (handle, tmpstr2);
  1691.  
  1692.             PrintOneLine (handle, "\nInterrupt Vectors:\n\n");
  1693.  
  1694.             sprintf (tmpstr2, " %18ls $%08lx %18ls $%08lx\n %18ls $%08lx %18ls $%08lx\n %18ls $%08lx %18ls $%08lx\n %18ls $%08lx %18ls $%08lx\n", "TBE  0:",SysBase->IntVects[0].iv_Code,"AUDIO1  8:",SysBase->IntVects[8].iv_Code,"DSKBLK  1:",SysBase->IntVects[1].iv_Code,"AUDIO2  9:",SysBase->IntVects[9].iv_Code,"SOFTINT  2:",SysBase->IntVects[2].iv_Code,"AUDIO3 10:",SysBase->IntVects[10].iv_Code,"PORTS  3:",SysBase->IntVects[3].iv_Code,"RBF 11:",SysBase->IntVects[11].iv_Code);
  1695.             PrintOneLine (handle, tmpstr2);
  1696.  
  1697.             sprintf (tmpstr2, " %18ls $%08lx %18ls $%08lx\n %18ls $%08lx %18ls $%08lx\n %18ls $%08lx %18ls $%08lx\n %18ls $%08lx %18ls $%08lx\n", "COPPER  4:",SysBase->IntVects[4].iv_Code,"DSKSYNC 12:",SysBase->IntVects[12].iv_Code,"VERTB  5:",SysBase->IntVects[5].iv_Code,"EXTER 13:",SysBase->IntVects[13].iv_Code,"BLITTER  6:",SysBase->IntVects[6].iv_Code,"INTEN 14:",SysBase->IntVects[14].iv_Code,"AUDIO0  7:",SysBase->IntVects[7].iv_Code,"NMI 15:",SysBase->IntVects[15].iv_Code);
  1698.             PrintOneLine (handle, tmpstr2);
  1699.          }
  1700.       }
  1701.    }
  1702.    HandlePrintStop();
  1703. }
  1704.  
  1705. void GetVectors (void) {
  1706.    char  *VBR;
  1707.    int   i = 0;
  1708.  
  1709.    if (clientstate) {
  1710.       char  tmpbuffer[256];
  1711.  
  1712.       if (SendDaemon ("GetVectorList")) {
  1713.          if (sgets (client_socket, tmpbuffer, 256)) {
  1714.             MySetContents (vectext1, tmpbuffer);
  1715.             if (sgets (client_socket, tmpbuffer, 256)) {
  1716.                MySetContents (vectext2, tmpbuffer);
  1717.                if (sgets (client_socket, tmpbuffer, 256)) {
  1718.                   MySetContents (vectext3, tmpbuffer);
  1719.                   if (sgets (client_socket, tmpbuffer, 256)) {
  1720.                      MySetContents (vectext4, tmpbuffer);
  1721.                      if (sgets (client_socket, tmpbuffer, 256)) {
  1722.                         strcmp (tmpbuffer, CMD_DONE);
  1723.                      }
  1724.                   }
  1725.                }
  1726.             }
  1727.          }
  1728.       }
  1729.    } else {
  1730.       VBR = (char *) GetVBR ();
  1731.  
  1732.       MySetContents (vectext1, ESC "r$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x",SysBase->ColdCapture,SysBase->CoolCapture,SysBase->WarmCapture,SysBase->KickMemPtr,SysBase->KickTagPtr,SysBase->KickCheckSum);
  1733.       MySetContents (vectext2, ESC "r$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x",*((ULONG *) (VBR + 0x0064)),*((ULONG *) (VBR + 0x0068)),*((ULONG *) (VBR + 0x006c)),*((ULONG *) (VBR + 0x0070)),*((ULONG *) (VBR + 0x0074)),*((ULONG *) (VBR + 0x0078)),*((ULONG *) (VBR + 0x007c)));
  1734.       MySetContents (vectext3, ESC "r$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x",SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code);
  1735.       MySetContents (vectext4, ESC "r$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x",SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code);
  1736.    }
  1737. }
  1738.  
  1739. void SendVectorList (void) {
  1740.    char  *VBR;
  1741.    int   i = 0;
  1742.  
  1743.    VBR = (char *) GetVBR ();
  1744.  
  1745.    SendClient (ESC "r$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x",SysBase->ColdCapture,SysBase->CoolCapture,SysBase->WarmCapture,SysBase->KickMemPtr,SysBase->KickTagPtr,SysBase->KickCheckSum);
  1746.    SendClient (ESC "r$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x",*((ULONG *) (VBR + 0x0064)),*((ULONG *) (VBR + 0x0068)),*((ULONG *) (VBR + 0x006c)),*((ULONG *) (VBR + 0x0070)),*((ULONG *) (VBR + 0x0074)),*((ULONG *) (VBR + 0x0078)),*((ULONG *) (VBR + 0x007c)));
  1747.    SendClient (ESC "r$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x",SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code);
  1748.    SendClient (ESC "r$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x\n$%08x",SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code,SysBase->IntVects[i++].iv_Code);
  1749. }
  1750.  
  1751.  
  1752. /*********************************************************************
  1753.                                Allocations
  1754. *********************************************************************/
  1755.  
  1756. static char alcnonalc[] = "<free>";
  1757. static char alcunknown[] = "<allocated>";
  1758. static char alcnotavail[] = "<not available>";
  1759.  
  1760. static char * AlcMiscUser(ULONG unit) {
  1761.   char * name;
  1762.  
  1763.   if(!MiscBase) return(alcnotavail);
  1764.  
  1765.   if(!(name = AllocMiscResource(unit,"Scout")))
  1766.     FreeMiscResource(unit);
  1767.   return(name ? name : alcnonalc);
  1768. }
  1769.  
  1770. static char * AlcCiaAUser(WORD unit) {
  1771.   struct Interrupt *intr;
  1772.   char * name;
  1773.  
  1774.   if(!CiaABase) return(alcnotavail);
  1775.  
  1776.   Disable();
  1777.   if(!(intr = AddICRVector(CiaABase,unit,&DummyInt))) {
  1778.     RemICRVector(CiaABase,unit,&DummyInt);
  1779.     Enable();
  1780.     return(alcnonalc);
  1781.   }
  1782.   Enable();
  1783.   name = intr->is_Node.ln_Name;
  1784.   return(name ? name : alcunknown);
  1785. }
  1786.  
  1787. static char * AlcCiaBUser(WORD unit) {
  1788.   struct Interrupt *intr;
  1789.   char * name;
  1790.  
  1791.   if(!CiaBBase) return(alcnotavail);
  1792.  
  1793.   Disable();
  1794.   if(!(intr = AddICRVector(CiaBBase,unit,&DummyInt))) {
  1795.     RemICRVector(CiaBBase,unit,&DummyInt);
  1796.     Enable();
  1797.     return(alcnonalc);
  1798.   }
  1799.   Enable();
  1800.   name = intr->is_Node.ln_Name;
  1801.   return(name ? name : alcunknown);
  1802. }
  1803.  
  1804.  
  1805. void PrintAllocations (char *filename) {
  1806.    BPTR  handle;
  1807.  
  1808.    handle = HandlePrintStart (filename);
  1809.    if (handle) {
  1810.       if (clientstate) {
  1811.          char  tmpbuffer[256];
  1812.  
  1813.          if (SendDaemon ("Allocations")) {
  1814.             while ((sgets (client_socket, tmpbuffer, 256)) \
  1815.               && (strcmp (tmpbuffer, CMD_DONE)) \
  1816.               && (strcmp (tmpbuffer, CMD_ERROR))) {
  1817.                PrintOneLine (handle, tmpbuffer);
  1818.             }
  1819.          }
  1820.       } else {
  1821.          if (PrintOneLine (handle, "\nCIA A:\n\n")) {
  1822.             sprintf(tmpstr2, "Timer A: %s\nTimer B: %s\n  Alarm: %s\n Serial: %s\n   Flag: %s",AlcCiaAUser(0),AlcCiaAUser(1),AlcCiaAUser(2),AlcCiaAUser(3),AlcCiaAUser(4));
  1823.             PrintOneLine (handle, tmpstr2);
  1824.  
  1825.             PrintOneLine (handle, "\n\n\nCIA B:\n\n");
  1826.             sprintf(tmpstr2, "Timer A: %s\nTimer B: %s\n  Alarm: %s\n Serial: %s\n   Flag: %s",AlcCiaBUser(0),AlcCiaBUser(1),AlcCiaBUser(2),AlcCiaBUser(3),AlcCiaBUser(4));
  1827.             PrintOneLine (handle, tmpstr2);
  1828.  
  1829.             PrintOneLine (handle, "\n\n\nSerial & Parallel Ports:\n\n");
  1830.             sprintf(tmpstr2, "     Serial Port: %s\n  Serial Control: %s\n   Parallel Port: %s\nParallel Control: %s",AlcMiscUser(MR_SERIALPORT),AlcMiscUser(MR_SERIALBITS),AlcMiscUser(MR_PARALLELPORT),AlcMiscUser(MR_PARALLELBITS));
  1831.             PrintOneLine (handle, tmpstr2);
  1832.          }
  1833.       }
  1834.    }
  1835.    HandlePrintStop();
  1836. }
  1837.  
  1838. void GetAllocations (void) {
  1839.    if (clientstate) {
  1840.       char  tmpbuffer[256];
  1841.  
  1842.       if (SendDaemon ("GetAlcList")) {
  1843.          if (sgets (client_socket, tmpbuffer, 256)) {
  1844.             MySetContents (alctext1, tmpbuffer);
  1845.             if (sgets (client_socket, tmpbuffer, 256)) {
  1846.                MySetContents (alctext2, tmpbuffer);
  1847.                if (sgets (client_socket, tmpbuffer, 256)) {
  1848.                   MySetContents (alctext3, tmpbuffer);
  1849.                   if (sgets (client_socket, tmpbuffer, 256)) {
  1850.                      strcmp (tmpbuffer, CMD_DONE);
  1851.                   }
  1852.                }
  1853.             }
  1854.          }
  1855.       }
  1856.    } else {
  1857.       Forbid();
  1858.       MySetContents (alctext1, "%s\n%s\n%s\n%s\n%s",AlcCiaAUser(0),AlcCiaAUser(1),AlcCiaAUser(2),AlcCiaAUser(3),AlcCiaAUser(4));
  1859.       MySetContents (alctext2, "%s\n%s\n%s\n%s\n%s",AlcCiaBUser(0),AlcCiaBUser(1),AlcCiaBUser(2),AlcCiaBUser(3),AlcCiaBUser(4));
  1860.       MySetContents (alctext3, "%s\n%s\n%s\n%s",AlcMiscUser(MR_SERIALPORT),AlcMiscUser(MR_SERIALBITS),AlcMiscUser(MR_PARALLELPORT),AlcMiscUser(MR_PARALLELBITS));
  1861.       Permit();
  1862.    }
  1863. }
  1864.  
  1865. void SendAlcList (void) {
  1866.    SendClient (ESC "r%s\n%s\n%s\n%s\n%s",AlcCiaAUser(0),AlcCiaAUser(1),AlcCiaAUser(2),AlcCiaAUser(3),AlcCiaAUser(4));
  1867.    SendClient (ESC "r%s\n%s\n%s\n%s\n%s",AlcCiaBUser(0),AlcCiaBUser(1),AlcCiaBUser(2),AlcCiaBUser(3),AlcCiaBUser(4));
  1868.    SendClient (ESC "r%s\n%s\n%s\n%s",AlcMiscUser(MR_SERIALPORT),AlcMiscUser(MR_SERIALBITS),AlcMiscUser(MR_PARALLELPORT),AlcMiscUser(MR_PARALLELBITS));
  1869. }
  1870.  
  1871.  
  1872. /*********************************************************************
  1873.                                System
  1874. *********************************************************************/
  1875. struct   SystemEntry {
  1876.    struct SystemEntry  *syse_next;
  1877.    char  syse_desc[30];
  1878.    char  syse_line[100];
  1879. };
  1880.  
  1881. __asm LONG syslist_dspfunc(register __a2 char **array, register __a1 struct SystemEntry *sysentry, register __a0 struct Hook *hook) {
  1882.    if (sysentry) {
  1883.       *array++ = sysentry->syse_desc;
  1884.       *array   = sysentry->syse_line;
  1885.    }
  1886.    return(0);
  1887. }
  1888.  
  1889. struct Hook syslist_dsphook = {
  1890.  {NULL, NULL},
  1891.  (ULONG (* )())syslist_dspfunc,
  1892.  NULL, NULL
  1893. };
  1894.  
  1895. void FreeSystem (void) {
  1896.    MyFreeStructs (&SysRememberKey, systext, syslist);
  1897. }
  1898.  
  1899. static struct SystemEntry * genentry(struct SystemEntry **first, struct SystemEntry **previous, int *syscnt)
  1900. {
  1901.   struct SystemEntry *sysentry;
  1902.  
  1903.   if(sysentry = AllocRemember (&SysRememberKey, sizeof (struct SystemEntry), MEMF_ANY|MEMF_CLEAR)) {
  1904.     if (! *first)
  1905.        *first = sysentry;
  1906.     if (*previous)
  1907.        (*previous)->syse_next = sysentry;
  1908.     (*syscnt)++;
  1909.     *previous = sysentry;
  1910.   }
  1911.   return(sysentry);
  1912. }
  1913.  
  1914. STRPTR MyIdHardware(ULONG num)
  1915. {
  1916.   return IdHardwareTags(num,IDTAG_Localize,FALSE,TAG_DONE);
  1917. }
  1918. int MyIdCheck(ULONG num)
  1919. {
  1920.   return (int)IdHardwareTags(num,IDTAG_NULL4NA,TRUE,TAG_DONE);
  1921. }
  1922.  
  1923. int GetSystem (struct SystemEntry **first) {
  1924.    struct   SystemEntry    *sysentry,*previous = NULL;
  1925.    int syscnt = 0;
  1926.  
  1927.    ULONG cacr = GetCACR(); /* 68020..68060 */
  1928.    ULONG pcr  = GetPCR();  /* 68060 */
  1929.    UWORD attn = SysBase->AttnFlags;
  1930.  
  1931.    *first = 0;
  1932.  
  1933.    if (clientstate) {
  1934.       if (SendDaemon ("GetSysList")) {
  1935.          while ((sysentry = AllocRemember (&SysRememberKey, sizeof (struct SystemEntry), MEMF_ANY|MEMF_CLEAR)) \
  1936.            && (ReceiveDecodedEntry ((UBYTE *) sysentry, sizeof (struct SystemEntry)))) {
  1937.  
  1938.             if (! *first)
  1939.                *first = sysentry;
  1940.             if (previous)
  1941.                previous->syse_next = sysentry;
  1942.  
  1943.             syscnt++;
  1944.             previous = sysentry;
  1945.          }
  1946.       }
  1947.    } else if(!IdentifyBase) {
  1948.       if(sysentry = genentry(first,&previous,&syscnt)) {
  1949.          strcpy (sysentry->syse_line,ESC "8identify.library not available!");
  1950.       }
  1951.    } else {
  1952.       ULONG lastalert;
  1953.  
  1954.       IdHardwareUpdate();                 /* Liste auf dem aktuellsten Stand */
  1955.  
  1956.       if(sysentry = genentry(first,&previous,&syscnt)) {
  1957.          strcpy (sysentry->syse_line,ESC "c" ESC "8-- HARDWARE --");
  1958.       }
  1959.       genentry(first,&previous,&syscnt);
  1960.  
  1961.       if(sysentry = genentry(first,&previous,&syscnt)) {
  1962.          strcpy (sysentry->syse_desc,"System");
  1963.          sprintf(sysentry->syse_line,"%s",IdHardware(IDHW_SYSTEM,NULL));
  1964.       }
  1965.       genentry(first,&previous,&syscnt);
  1966.       if(sysentry = genentry(first,&previous,&syscnt)) {
  1967.          strcpy (sysentry->syse_desc,"Processor");
  1968.          if(MyIdCheck(IDHW_CPUREV))
  1969.            sprintf(sysentry->syse_line,"CPU: %s / %s (ID $%04lx, Rev %s)", MyIdHardware(IDHW_CPU), MyIdHardware(IDHW_CPUCLOCK), pcr>>16, MyIdHardware(IDHW_CPUREV));
  1970.          else
  1971.            sprintf(sysentry->syse_line,"CPU: %s / %s", MyIdHardware(IDHW_CPU), MyIdHardware(IDHW_CPUCLOCK));
  1972.       }
  1973.  
  1974.       if(MyIdCheck(IDHW_FPU)) {
  1975.         if(sysentry = genentry(first,&previous,&syscnt)) {
  1976.            sprintf(sysentry->syse_line,"FPU: %s / %s", MyIdHardware(IDHW_FPU), MyIdHardware(IDHW_FPUCLOCK));
  1977.         }
  1978.       }
  1979.  
  1980.       if(MyIdCheck(IDHW_MMU)) {
  1981.         if(sysentry = genentry(first,&previous,&syscnt)) {
  1982.            sprintf(sysentry->syse_line,"MMU: %s", MyIdHardware(IDHW_MMU));
  1983.         }
  1984.       }
  1985.  
  1986.       if(MyIdCheck(IDHW_POWERPC)) {
  1987.         if(sysentry = genentry(first,&previous,&syscnt)) {
  1988.            sprintf(sysentry->syse_line,"PPC: %s / %s", MyIdHardware(IDHW_POWERPC), MyIdHardware(IDHW_PPCCLOCK));
  1989.         }
  1990.       }
  1991.  
  1992.       genentry(first,&previous,&syscnt);
  1993.       if(sysentry = genentry(first,&previous,&syscnt)) {
  1994.          strcpy (sysentry->syse_desc,"Chipset");
  1995.          sprintf(sysentry->syse_line,"%s, RamSey %s, Gary %s",MyIdHardware(IDHW_CHIPSET),MyIdHardware(IDHW_RAMSEY),MyIdHardware(IDHW_GARY));
  1996.       }
  1997.       if(sysentry = genentry(first,&previous,&syscnt)) {
  1998.          sprintf(sysentry->syse_line,"ChunkyPlanar %s, BattClock %s",MyIdHardware(IDHW_CHUNKYPLANAR),MyIdHardware(IDHW_BATTCLOCK));
  1999.       }
  2000.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2001.          strcpy (sysentry->syse_desc,"Mother RAM");
  2002.          sprintf(sysentry->syse_line,"%s Bit, %s Access, %s CAS, %sx Bandwidth",MyIdHardware(IDHW_RAMWIDTH),MyIdHardware(IDHW_RAMACCESS),MyIdHardware(IDHW_RAMCAS),MyIdHardware(IDHW_RAMBANDWIDTH));
  2003.       }
  2004.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2005.          strcpy (sysentry->syse_desc,"Frequencies");
  2006.          sprintf(sysentry->syse_line,"VBlank %s, Power %s, E %s",MyIdHardware(IDHW_VBLANKFREQ),MyIdHardware(IDHW_POWERFREQ),MyIdHardware(IDHW_ECLOCK));
  2007.       }
  2008.  
  2009.       if(attn & AFF_68010) {
  2010.          ULONG cache = CacheControl(0,0);
  2011.  
  2012.          genentry(first,&previous,&syscnt);
  2013.          genentry(first,&previous,&syscnt);
  2014.          if(sysentry = genentry(first,&previous,&syscnt)) {
  2015.             strcpy (sysentry->syse_line,ESC "c" ESC "8-- REGISTERS --");
  2016.          }
  2017.          genentry(first,&previous,&syscnt);
  2018.  
  2019.          if(sysentry = genentry(first,&previous,&syscnt)) {
  2020.             sprintf(sysentry->syse_line,"VBR  $%08lx",GetVBR());
  2021.          }
  2022.  
  2023.          if(attn & AFF_68020)
  2024.          {
  2025.             if(sysentry = genentry(first,&previous,&syscnt)) {
  2026.                sprintf(sysentry->syse_line,"CACR $%08lx",cacr);
  2027.             }
  2028.          }
  2029.  
  2030.          if(attn & AFF_68060)
  2031.          {
  2032.             if(sysentry = genentry(first,&previous,&syscnt)) {
  2033.                sprintf(sysentry->syse_line,"PCR  $%08lx",pcr);
  2034.             }
  2035.          }
  2036.          genentry(first,&previous,&syscnt);
  2037.  
  2038.          if(attn & AFF_68020) {
  2039.             if(sysentry = genentry(first,&previous,&syscnt)) {
  2040.                strcpy(sysentry->syse_desc,"Inst Cache");
  2041.                if(cache&CACRF_EnableI){
  2042.                   strcpy(sysentry->syse_line,"Enabled ");
  2043.                   if((attn&AFF_68030) && (!(attn&AFF_68040)) && (cache&CACRF_IBE)) strcat(sysentry->syse_line,"Burst ");
  2044.                   if(cache&CACRF_FreezeI) strcat(sysentry->syse_line,"Frozen ");
  2045.                   if((attn&AFF_68060) && (cacr&(1<<13))) strcat(sysentry->syse_line,"Half ");
  2046.                 }else{
  2047.                   strcpy(sysentry->syse_line,"Disabled");
  2048.                 }
  2049.             }
  2050.          }
  2051.  
  2052.          if(attn & AFF_68030) {
  2053.             if(sysentry = genentry(first,&previous,&syscnt)) {
  2054.                strcpy(sysentry->syse_desc,"Data Cache");
  2055.                if(cache&CACRF_EnableD){
  2056.                   strcpy(sysentry->syse_line,"Enabled ");
  2057.                   if((attn&AFF_68030) && (!(attn&AFF_68040)) && (cache&CACRF_DBE)) strcat(sysentry->syse_line,"Burst ");
  2058.                   if(cache&CACRF_FreezeD) strcat(sysentry->syse_line,"Frozen ");
  2059.                   if((attn&AFF_68060) && (cacr&(1<<27))) strcat(sysentry->syse_line,"Half ");
  2060.                   if((attn&AFF_68030) && (!(attn&AFF_68040)) && (cache&CACRF_WriteAllocate)) strcat(sysentry->syse_line,"Allocate ");
  2061.                 }else{
  2062.                   strcpy(sysentry->syse_line,"Disabled");
  2063.                 }
  2064.             }
  2065.          }
  2066.  
  2067.          if((attn&AFF_68040) && (!(attn&AFF_68060)) && (cache&CACRF_CopyBack)){
  2068.             if(sysentry = genentry(first,&previous,&syscnt)) {
  2069.                sprintf(sysentry->syse_line,"CopyBack");
  2070.             }
  2071.          }
  2072.          if(cache&CACRF_EnableE){
  2073.             if(sysentry = genentry(first,&previous,&syscnt)) {
  2074.                sprintf(sysentry->syse_line,"External Cache");
  2075.             }
  2076.          }
  2077.          if(attn & AFF_68060)
  2078.          {
  2079.             if(pcr&(1<<0))
  2080.               if(sysentry = genentry(first,&previous,&syscnt)) {
  2081.                  sprintf(sysentry->syse_line,"Superscalar");
  2082.               }
  2083.             if(cacr&(1<<23))
  2084.               if(sysentry = genentry(first,&previous,&syscnt)) {
  2085.                  sprintf(sysentry->syse_line,"Branch Cache");
  2086.               }
  2087.             if(cacr&(1<<29))
  2088.               if(sysentry = genentry(first,&previous,&syscnt)) {
  2089.                  sprintf(sysentry->syse_line,"Store Buffer");
  2090.               }
  2091.             if(cacr&(1<<28))
  2092.               if(sysentry = genentry(first,&previous,&syscnt)) {
  2093.                  sprintf(sysentry->syse_line,"CPUSH invalidation disabled");
  2094.               }
  2095.             if(pcr&(1<<1))
  2096.               if(sysentry = genentry(first,&previous,&syscnt)) {
  2097.                  sprintf(sysentry->syse_line,"FPU disabled");
  2098.               }
  2099.          }
  2100.       }
  2101.  
  2102.       genentry(first,&previous,&syscnt);
  2103.       genentry(first,&previous,&syscnt);
  2104.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2105.          strcpy (sysentry->syse_line,ESC "c" ESC "8-- VERSIONS --");
  2106.       }
  2107.       genentry(first,&previous,&syscnt);
  2108.  
  2109.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2110.          strcpy (sysentry->syse_desc,"AmigaOS");
  2111.          sprintf(sysentry->syse_line,"%s (= %s), SetPatch %s, ROM %s",MyIdHardware(IDHW_OSNR),MyIdHardware(IDHW_OSVER),MyIdHardware(IDHW_SETPATCHVER),MyIdHardware(IDHW_ROMSIZE));
  2112.       }
  2113.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2114.          strcpy (sysentry->syse_desc,"Exec");
  2115.          sprintf(sysentry->syse_line,"%s",MyIdHardware(IDHW_EXECVER));
  2116.       }
  2117.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2118.          strcpy (sysentry->syse_desc,"Workbench");
  2119.          sprintf(sysentry->syse_line,"%s",MyIdHardware(IDHW_WBVER));
  2120.       }
  2121.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2122.          strcpy (sysentry->syse_desc,"Graphics");
  2123.          sprintf(sysentry->syse_line,"%s",MyIdHardware(IDHW_GFXSYS));
  2124.       }
  2125.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2126.          strcpy (sysentry->syse_desc,"Audio");
  2127.          sprintf(sysentry->syse_line,"%s",MyIdHardware(IDHW_AUDIOSYS));
  2128.       }
  2129.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2130.          strcpy (sysentry->syse_desc,"TCP/IP");
  2131.          sprintf(sysentry->syse_line,"%s",MyIdHardware(IDHW_TCPIP));
  2132.       }
  2133.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2134.          strcpy (sysentry->syse_desc,"PowerPC-OS");
  2135.          sprintf(sysentry->syse_line,"%s",MyIdHardware(IDHW_PPCOS));
  2136.       }
  2137.  
  2138.       genentry(first,&previous,&syscnt);
  2139.       genentry(first,&previous,&syscnt);
  2140.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2141.          strcpy (sysentry->syse_line,ESC "c" ESC "8-- MEMORY --");
  2142.       }
  2143.       genentry(first,&previous,&syscnt);
  2144.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2145.          sprintf(sysentry->syse_line," Chip       Fast      TOTAL");
  2146.       }
  2147.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2148.          strcpy (sysentry->syse_desc,"Plain");
  2149.          sprintf(sysentry->syse_line,"%9s  %9s  %9s",MyIdHardware(IDHW_PLNCHIPRAM),MyIdHardware(IDHW_PLNFASTRAM),MyIdHardware(IDHW_PLNRAM));
  2150.       }
  2151.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2152.          strcpy (sysentry->syse_desc,"Virtual");
  2153.          sprintf(sysentry->syse_line,"%9s  %9s  %9s",MyIdHardware(IDHW_VMMCHIPRAM),MyIdHardware(IDHW_VMMFASTRAM),MyIdHardware(IDHW_VMMRAM));
  2154.       }
  2155.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2156.          strcpy (sysentry->syse_desc,"TOTAL");
  2157.          sprintf(sysentry->syse_line,"%9s  %9s  %9s",MyIdHardware(IDHW_CHIPRAM),MyIdHardware(IDHW_FASTRAM),MyIdHardware(IDHW_RAM));
  2158.       }
  2159.       genentry(first,&previous,&syscnt);
  2160.       if(sysentry = genentry(first,&previous,&syscnt)) {
  2161.          sprintf(sysentry->syse_line,"SlowRAM: %s",MyIdHardware(IDHW_SLOWRAM));
  2162.       }
  2163.  
  2164.       lastalert = IdHardwareNum(IDHW_LASTALERT,NULL);
  2165.       if(lastalert != 0xFFFFFFFF) {
  2166.          genentry(first,&previous,&syscnt);
  2167.          genentry(first,&previous,&syscnt);
  2168.          if(sysentry = genentry(first,&previous,&syscnt)) {
  2169.             strcpy (sysentry->syse_line,ESC "c" ESC "8-- LAST ALERT --");
  2170.          }
  2171.          genentry(first,&previous,&syscnt);
  2172.          if(sysentry = genentry(first,&previous,&syscnt)) {
  2173.             strcpy (sysentry->syse_desc,"Alert Code");
  2174.             sprintf(sysentry->syse_line,"%08lx",lastalert);
  2175.          }
  2176.          if(sysentry = genentry(first,&previous,&syscnt)) {
  2177.             strcpy (sysentry->syse_desc,"Deadend");
  2178.             IdAlertTags(lastalert,IDTAG_DeadStr,sysentry->syse_line,TAG_DONE);
  2179.          }
  2180.          if(sysentry = genentry(first,&previous,&syscnt)) {
  2181.             strcpy (sysentry->syse_desc,"Sub System");
  2182.             IdAlertTags(lastalert,IDTAG_SubsysStr,sysentry->syse_line,TAG_DONE);
  2183.          }
  2184.          if(sysentry = genentry(first,&previous,&syscnt)) {
  2185.             strcpy (sysentry->syse_desc,"General");
  2186.             IdAlertTags(lastalert,IDTAG_GeneralStr,sysentry->syse_line,TAG_DONE);
  2187.          }
  2188.          if(sysentry = genentry(first,&previous,&syscnt)) {
  2189.             strcpy (sysentry->syse_desc,"Specific");
  2190.             IdAlertTags(lastalert,IDTAG_SpecStr,sysentry->syse_line,TAG_DONE);
  2191.          }
  2192.       }
  2193.    }
  2194.    return (syscnt);
  2195. }
  2196.  
  2197. void PrintSystem (char *filename) {
  2198.    int   i=1;
  2199.    BPTR  handle;
  2200.    struct SystemEntry *entryp;
  2201.    STRPTR desc,line;
  2202.  
  2203.    handle = HandlePrintStart (filename);
  2204.    if (handle) {
  2205.       if (! WI_System) {
  2206.          i = GetSystem (&entryp);
  2207.       }
  2208.       if (i) {
  2209.          for (i=0;;i++) {
  2210.             if (WI_System)
  2211.                DoMethod (syslist,MUIM_List_GetEntry,i,&entryp);
  2212.             if (!entryp) break;
  2213.  
  2214.             desc = entryp->syse_desc; while(*desc=='\33') desc+=2;
  2215.             line = entryp->syse_line; while(*line=='\33') line+=2;
  2216.  
  2217.             sprintf (tmpstr2, " %15ls  %ls\n",desc,line);
  2218.             if (! (PrintOneLine (handle, tmpstr2)))
  2219.                break;
  2220.  
  2221.             if (! WI_System)
  2222.                entryp = entryp->syse_next;
  2223.          }
  2224.       }
  2225.    }
  2226.    HandlePrintStop();
  2227. }
  2228.  
  2229. void ShowSystem (void) {
  2230.    struct SystemEntry *syse;
  2231.  
  2232.    ApplicationSleep();
  2233.    set (syslist,MUIA_List_Quiet,TRUE);
  2234.  
  2235.    FreeSystem();
  2236.    GetSystem(&syse);
  2237.  
  2238.    while (syse) {
  2239.       InsertBottomEntry (syslist, (APTR *) &syse);
  2240.       syse = syse->syse_next;
  2241.    }
  2242.  
  2243.    AwakeApplication();
  2244.    set (syslist,MUIA_List_Quiet,FALSE);
  2245. }
  2246.  
  2247. void SendSystemList (void) {
  2248.    struct   SystemEntry   *syse;
  2249.  
  2250.    FreeSystem();
  2251.    GetSystem (&syse);
  2252.  
  2253.    while (syse) {
  2254.       SendEncodedEntry ((UBYTE *) syse, sizeof (struct SystemEntry));
  2255.       syse = syse->syse_next;
  2256.    }
  2257.    FreeSystem();
  2258. }
  2259.  
  2260.  
  2261. /*********************************************************************
  2262. *********************************************************************/
  2263.  
  2264. __asm int priority_callfunc(register __a1 char **contents) {
  2265.    unsigned char  *pristring;
  2266.    int pri=0,length;
  2267.  
  2268.    get (pritext3,MUIA_String_Contents,&pristring);
  2269.  
  2270.         if (((length = stcd_i (pristring,&pri)) == strlen (pristring)) && \
  2271.                 (pri >= -128) && (pri <= 127)) {
  2272.       set (SL_Priority,MUIA_Slider_Level,pri);
  2273.       set (WI_Priority,MUIA_Window_ActiveObject,BT_PriorityOK);
  2274.    } else {
  2275.       set (WI_Priority,MUIA_Window_ActiveObject,pritext3);
  2276.    }
  2277.    
  2278.    return (pri);
  2279. }
  2280.  
  2281. struct Hook priority_callhook = {
  2282.  {NULL, NULL},
  2283.  (ULONG (* )())priority_callfunc,
  2284.  NULL, NULL
  2285. };
  2286.  
  2287. BOOL GetPriority (char *nodename, char *pritext, LONG *pri) {
  2288.    BOOL  running = TRUE, result = FALSE;
  2289.    LONG  oldpri;
  2290.    ULONG signal;
  2291.  
  2292.    IsDec (pritext, &oldpri);
  2293.  
  2294.    WI_Priority = WindowObject,
  2295.  
  2296.    MUIA_Window_Title, "SCOUT: Change priority",
  2297.    MUIA_Window_ID, MakeID('P','R','I','O'),
  2298.    WindowContents, VGroup,
  2299.       Child, MyVSpace(2),
  2300.       Child, pritext1 = MyTextObject(),
  2301.       Child, MyVSpace(2),
  2302.       Child, SL_Priority = SliderObject,
  2303.          MUIA_Slider_Min, -128,
  2304.          MUIA_Slider_Max, 127,
  2305.          MUIA_Slider_Level, 0,
  2306.          MUIA_Slider_Quiet, TRUE,
  2307.          MUIA_FixHeightTxt, " ",
  2308.       End,
  2309.       Child, MyVSpace(2),
  2310.       Child, HGroup, MUIA_Group_SameWidth, TRUE,
  2311.          Child, HGroup,
  2312.             Child, MyLabel2 ("Min:"),
  2313.             Child, MyTextObject3(ESC "c -128 "), 
  2314.          End,
  2315.          Child, HGroup,
  2316.             Child, MyLabel2 ("Max:"),
  2317.             Child, MyTextObject3(ESC "c127"), 
  2318.          End,
  2319.          Child, HGroup,
  2320.             Child, MyLabel2 ("Old:"),
  2321.             Child, pritext2 = MyTextObject(), 
  2322.          End,
  2323.          Child, HGroup,
  2324.             Child, MyLabel2 ("New:"),
  2325.             Child, pritext3 = StringObject,
  2326.                MUIA_String_BufferPos, 1,
  2327.                MUIA_String_Accept , "-0123456879",
  2328.                MUIA_String_Integer, oldpri,
  2329.                MUIA_String_MaxLen, 5, StringFrame,
  2330.             End,
  2331.          End,
  2332.       End,
  2333.       Child, MyVSpace(2),
  2334.       Child, HGroup, MUIA_Group_SameWidth, TRUE,
  2335.          Child, BT_PriorityOK     = KeyButtonA (OKText    ,ID_PRIORITYOK),
  2336.          Child, BT_PriorityCancel = KeyButtonA (CancelText,ID_PRIORITYEXIT),
  2337.       End,
  2338.    End, End;
  2339.  
  2340.    if (WI_Priority) {
  2341.       MySetContents (pritext1, ESC "c Please select a new priority for \n'%s'! ", nodename);
  2342.       MySetContents (pritext2, ESC "c%d",oldpri);
  2343.       set (SL_Priority,MUIA_Slider_Level,oldpri);
  2344.       set (pritext3,MUIA_Text_Contents,tmpstr);
  2345.  
  2346.       ApplicationSleep();
  2347.  
  2348.       DoMethod (AP_Scout,OM_ADDMEMBER,WI_Priority);
  2349.       DoMethod (WI_Priority,MUIM_Window_SetCycleChain,SL_Priority,pritext3,BT_PriorityCancel,BT_PriorityOK,NULL);
  2350.       SetCloseRequest (WI_Priority,(int) ID_PRIORITYEXIT);
  2351.  
  2352.       DoMethod (SL_Priority,MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,pritext3,4,MUIM_SetAsString,MUIA_String_Contents,"%ld",MUIV_TriggerValue);
  2353.       DoMethod (pritext3,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,pritext3,3,MUIM_CallHook,&priority_callhook,MUIV_TriggerValue);
  2354.  
  2355.       SetWindowOpen (WI_Priority,SL_Priority,NULL);
  2356.  
  2357.       while (running) {
  2358.          switch (DoMethod(AP_Scout,MUIM_Application_Input,&signal)) {
  2359.             case ID_PRIORITYOK:
  2360.                get (SL_Priority,MUIA_Slider_Level,pri);
  2361.                result = TRUE;
  2362.                running = FALSE;
  2363.                break;
  2364.  
  2365.             case ID_PRIORITYEXIT:
  2366.                running = FALSE;
  2367.                break;
  2368.  
  2369.             default:
  2370.                break;
  2371.          }
  2372.          if (running && signal)
  2373.             Wait (signal);
  2374.       }
  2375.  
  2376.       SetWindowClose (WI_Priority,FALSE);
  2377.       AwakeApplication();
  2378.  
  2379.       DoMethod (AP_Scout,OM_REMMEMBER,WI_Priority);
  2380.       MUI_DisposeObject (WI_Priority);
  2381.       WI_Priority = NULL;
  2382.    }
  2383.    return (result);
  2384. }
  2385.  
  2386. BOOL GetSignal (char *taskname, char *waitsignal, char *resultstring) {
  2387.    BOOL  running = TRUE, result = FALSE;
  2388.    LONG  signal;
  2389.    char  *textptr;
  2390.  
  2391.    WI_Signal = WindowObject,
  2392.  
  2393.    MUIA_Window_Title, "SCOUT: Send signal",
  2394.    MUIA_Window_ID, MakeID('S','E','N','D'),
  2395.    WindowContents, VGroup,
  2396.       Child, MyVSpace(2),
  2397.       Child, sigtext1 = MyTextObject(),
  2398.       Child, MyVSpace(2),
  2399.       Child, HGroup, MUIA_Group_SameWidth, TRUE,
  2400.          Child, HGroup,
  2401.             Child, KeyLabel("Signal:", 's'),
  2402.             Child, sigtext2 = StringObject,
  2403.                MUIA_ControlChar, 's',
  2404.                MUIA_String_MaxLen, 10, StringFrame,
  2405.                MUIA_String_EditHook, &hexstring_edithook,
  2406.             End,
  2407.          End,
  2408.          Child, HGroup,
  2409.             Child, MyLabel ("SigWait:"),
  2410.             Child, sigtext3 = MyTextObject(), 
  2411.          End,
  2412.       End,
  2413.       Child, MyVSpace(2),
  2414.       Child, HGroup, MUIA_Group_SameWidth, TRUE,
  2415.          Child, BT_SignalOK     = KeyButtonA (OKText    ,ID_SIGNALOK),
  2416.          Child, BT_SignalCancel = KeyButtonA (CancelText,ID_SIGNALEXIT),
  2417.       End,
  2418.    End, End;
  2419.  
  2420.    if (WI_Signal) {
  2421.       MySetContents (sigtext1, ESC "c Please select the signal for \n'%ls'! ", taskname);
  2422.       set (sigtext2, MUIA_String_Contents, waitsignal);
  2423.       MySetContents (sigtext3, ESC "c%ls", waitsignal);
  2424.  
  2425.       ApplicationSleep();
  2426.  
  2427.       DoMethod (AP_Scout,OM_ADDMEMBER,WI_Signal);
  2428.       DoMethod (WI_Signal,MUIM_Window_SetCycleChain,sigtext2,BT_SignalOK,BT_SignalCancel,NULL);
  2429.       SetCloseRequest (WI_Signal,(int) ID_SIGNALEXIT);
  2430.  
  2431.       SetWindowOpen (WI_Signal,sigtext2,NULL);
  2432.  
  2433.       while (running) {
  2434.          switch (DoMethod(AP_Scout,MUIM_Application_Input,&signal)) {
  2435.             case ID_SIGNALOK:
  2436.                get (sigtext2,MUIA_String_Contents,&textptr);
  2437.                strcpy (resultstring, textptr);
  2438.                running = FALSE;
  2439.                result = TRUE;
  2440.                break;
  2441.  
  2442.             case ID_SIGNALEXIT:
  2443.                running = FALSE;
  2444.                break;
  2445.  
  2446.             default:
  2447.                break;
  2448.          }
  2449.          if (running && signal)
  2450.             Wait (signal);
  2451.       }
  2452.  
  2453.       SetWindowClose (WI_Signal,FALSE);
  2454.       AwakeApplication();
  2455.  
  2456.       DoMethod (AP_Scout,OM_REMMEMBER,WI_Signal);
  2457.       MUI_DisposeObject (WI_Signal);
  2458.       WI_Signal = NULL;
  2459.    }
  2460.    return (result);
  2461. }
  2462.  
  2463. /*********************************************************************
  2464.                              LowMemory
  2465. *********************************************************************/
  2466. struct   LowMemoryEntry {
  2467.    struct LowMemoryEntry *lowmemory_next;
  2468.    struct Interrupt  *lowmemory_adr;
  2469.    char  lowmemory_address[10];
  2470.    char  lowmemory_name[NODENAMELENGTH+2];
  2471.    char  lowmemory_type[NODETYPELEN+1];
  2472.    char  lowmemory_pri[10];
  2473.    char  lowmemory_data[10];
  2474.    char  lowmemory_code[20];
  2475. };
  2476.  
  2477. __asm LONG lowmemorylist_dspfunc(register __a2 char **array, register __a1 struct LowMemoryEntry *lowmemoryentry, register __a0 struct Hook *hook) {
  2478.    if (lowmemoryentry) {
  2479.       *array++ = lowmemoryentry->lowmemory_address;
  2480.       *array++ = lowmemoryentry->lowmemory_name;
  2481.       *array++ = lowmemoryentry->lowmemory_type;
  2482.       *array++ = lowmemoryentry->lowmemory_pri;
  2483.       *array++ = lowmemoryentry->lowmemory_data;
  2484.       *array++ = lowmemoryentry->lowmemory_code;
  2485.       *array   = NULL;
  2486.    } else {
  2487.       *array++ = ESC "bAddress";
  2488.       *array++ = ESC "bln_Name";
  2489.       *array++ = ESC "bln_Type";
  2490.       *array++ = ESC "bln_Pri";
  2491.       *array++ = ESC "bis_Data";
  2492.       *array++ = ESC "bis_Code";
  2493.       *array++ = NULL;
  2494.    }
  2495.    return(0);
  2496. }
  2497.  
  2498. struct Hook lowmemorylist_dsphook = {
  2499.  {NULL, NULL},
  2500.  (ULONG (* )())lowmemorylist_dspfunc,
  2501.  NULL, NULL
  2502. };
  2503.  
  2504. void FreeLowMemory (void) {
  2505.    MyFreeStructs (&LowMemoryRememberKey, lowmemorytext, lowmemorylist);
  2506. }
  2507.  
  2508. int GetLowMemory (struct LowMemoryEntry **first) {
  2509.    struct   Interrupt      *intr;
  2510.    struct   LowMemoryEntry *lowmemoryentry,*previous = NULL;
  2511.    char     code[FILENAMELENGTH + 1];
  2512.  
  2513.    int lowmemorycnt = 0;
  2514.    *first = 0;
  2515.  
  2516.    if (clientstate) {
  2517.       if (SendDaemon ("GetLowMemList")) {
  2518.          while ((lowmemoryentry = AllocRemember (&LowMemoryRememberKey, sizeof (struct LowMemoryEntry), MEMF_ANY|MEMF_CLEAR)) \
  2519.            && (ReceiveDecodedEntry ((UBYTE *) lowmemoryentry, sizeof (struct LowMemoryEntry)))) {
  2520.             IsHex (lowmemoryentry->lowmemory_address, (long *) &lowmemoryentry->lowmemory_adr);
  2521.  
  2522.             if (! *first)
  2523.                *first = lowmemoryentry;
  2524.             if (previous)
  2525.                previous->lowmemory_next = lowmemoryentry;
  2526.  
  2527.             lowmemorycnt++;
  2528.             previous = lowmemoryentry;
  2529.          }
  2530.       }
  2531.    } else {
  2532.       if (SysBase->LibNode.lib_Version >= 39) {
  2533.          if (intr = (struct Interrupt *)SysBase->ex_MemHandlers.mlh_Head) {
  2534.             while ((intr->is_Node.ln_Succ != 0) && (lowmemoryentry = AllocRemember (&LowMemoryRememberKey, sizeof (struct LowMemoryEntry), MEMF_ANY|MEMF_CLEAR))) {
  2535.                if (! *first)
  2536.                   *first = lowmemoryentry;
  2537.                if (previous)
  2538.                   previous->lowmemory_next = lowmemoryentry;
  2539.  
  2540.                lowmemoryentry->lowmemory_adr = intr;
  2541.  
  2542.                code[0] = '\0';
  2543.                if (points2ram((APTR) intr->is_Code)) {
  2544.                   sprintf (code, HELL "$%08x" DUNKEL, intr->is_Code);
  2545.                } else {
  2546.                   sprintf (code, "$%08x", intr->is_Code);
  2547.                }
  2548.                sprintf (lowmemoryentry->lowmemory_address, "$%08x", intr);
  2549.                strncpy (lowmemoryentry->lowmemory_name, nonetest (intr->is_Node.ln_Name), 27);
  2550.                strcpy (lowmemoryentry->lowmemory_type, GetNodeType (intr->is_Node.ln_Type));
  2551.                sprintf (lowmemoryentry->lowmemory_pri, "%4d ", intr->is_Node.ln_Pri);
  2552.                sprintf (lowmemoryentry->lowmemory_data, "$%08x", intr->is_Data);
  2553.                strcpy (lowmemoryentry->lowmemory_code, code);
  2554.                lowmemorycnt++;
  2555.  
  2556.                previous = lowmemoryentry;
  2557.                intr = (struct Interrupt *) intr->is_Node.ln_Succ;
  2558.             }
  2559.          }
  2560.       }
  2561.    }
  2562.    return (lowmemorycnt);
  2563. }
  2564.  
  2565. void PrintLowMemory (char *filename) {
  2566.    int   i=1;
  2567.    BPTR  handle;
  2568.    struct LowMemoryEntry *entryp;
  2569.  
  2570.    handle = HandlePrintStart (filename);
  2571.    if ((handle) && (PrintOneLine (handle, "\n  Address  Type       Pri    Data       Code     Name\n\n"))) {
  2572.       if (! WI_LowMemory) {
  2573.          i = GetLowMemory (&entryp);
  2574.       }
  2575.       if (i) {
  2576.          for (i=0;;i++) {
  2577.             if (WI_LowMemory)
  2578.                DoMethod (lowmemorylist,MUIM_List_GetEntry,i,&entryp);
  2579.             if (!entryp) break;
  2580.  
  2581.             if (points2ram ((APTR) (entryp->lowmemory_adr->is_Code)))
  2582.                strcpy (tmpstr, entryp->lowmemory_code+2);
  2583.             else
  2584.                strcpy (tmpstr, entryp->lowmemory_code);
  2585.  
  2586.             sprintf (tmpstr2, " %ls %-9ls %4ls %ls %-9.9ls %ls\n", entryp->lowmemory_address, entryp->lowmemory_type, entryp->lowmemory_pri, entryp->lowmemory_data, tmpstr, entryp->lowmemory_name);
  2587.             if (! (PrintOneLine (handle, tmpstr2)))
  2588.                break;
  2589.  
  2590.             if (! WI_LowMemory)
  2591.                entryp = entryp->lowmemory_next;
  2592.          }
  2593.       }
  2594.    }
  2595.    HandlePrintStop();
  2596. }
  2597.  
  2598. void ShowLowMemory (void) {
  2599.    struct LowMemoryEntry *lowmemory;
  2600.  
  2601.    ApplicationSleep();
  2602.    set (lowmemorylist,MUIA_List_Quiet,TRUE);
  2603. //*   set (BT_LowMemoryCause, MUIA_Disabled, TRUE);
  2604.    set (BT_LowMemoryRemove, MUIA_Disabled, TRUE);
  2605.    set (BT_LowMemoryPriority, MUIA_Disabled, TRUE);
  2606.  
  2607.    FreeLowMemory();
  2608.    lowmemorycnt = GetLowMemory (&lowmemory);
  2609.  
  2610.    while (lowmemory) {
  2611.       InsertBottomEntry (lowmemorylist, (APTR *) &lowmemory);
  2612.       lowmemory = lowmemory->lowmemory_next;
  2613.    }
  2614.  
  2615.    SetCountText (lowmemorycount, lowmemorycnt);
  2616.    AwakeApplication();
  2617.    set (lowmemorylist,MUIA_List_Quiet,FALSE);
  2618. }
  2619.  
  2620. void SendLowMemory (void) {
  2621.    struct LowMemoryEntry *lowmemory;
  2622.  
  2623.    FreeLowMemory();
  2624.    lowmemorycnt = GetLowMemory (&lowmemory);
  2625.  
  2626.    while (lowmemory) {
  2627.       SendEncodedEntry ((UBYTE *) lowmemory, sizeof (struct LowMemoryEntry));
  2628.       lowmemory = lowmemory->lowmemory_next;
  2629.    }
  2630.    FreeLowMemory();
  2631. }
  2632.  
  2633. /*********************************************************************
  2634.                              Timer
  2635. *********************************************************************/
  2636. struct   TimerEntry {
  2637.    struct TimerEntry *timer_next;
  2638.    struct timerequest *timer_adr;
  2639.    char  timer_address[10];
  2640.    char  timer_name[NODENAMELENGTH+2];
  2641.    char  timer_replyport[10];
  2642.    char  timer_unit[20];
  2643.    char  timer_timeout[20];
  2644. };
  2645.  
  2646. __asm LONG timerlist_dspfunc(register __a2 char **array, register __a1 struct TimerEntry *timerentry, register __a0 struct Hook *hook) {
  2647.    if (timerentry) {
  2648.       *array++ = timerentry->timer_address;
  2649.       *array++ = timerentry->timer_replyport;
  2650.       *array++ = timerentry->timer_timeout;
  2651.       *array++ = timerentry->timer_unit;
  2652.       *array   = timerentry->timer_name;
  2653.    } else {
  2654.       *array++ = ESC "bAddress";
  2655.       *array++ = ESC "bReplyPort";
  2656.       *array++ = ESC "bTime";
  2657.       *array++ = ESC "bUnit";
  2658.       *array   = ESC "bTask";
  2659.    }
  2660.    return(0);
  2661. }
  2662.  
  2663. struct Hook timerlist_dsphook = {
  2664.  {NULL, NULL},
  2665.  (ULONG (* )())timerlist_dspfunc,
  2666.  NULL, NULL
  2667. };
  2668.  
  2669. void FreeTimer (void) {
  2670.    MyFreeStructs (&TimerRememberKey, timertext, timerlist);
  2671. }
  2672.  
  2673. int GetTimer (struct TimerEntry **first) {
  2674.    struct   timerequest *tr;
  2675.    struct   timerequest *search;
  2676.    struct   MsgPort *mp;
  2677.    struct   TimerEntry  *timerentry,*previous = NULL;
  2678.    char     code[FILENAMELENGTH + 1];
  2679.    ULONG    time, eclk, std, min, sec;
  2680.    struct   EClockVal eclock;
  2681.  
  2682.    int timercnt = 0;
  2683.    *first = 0;
  2684.  
  2685.    if (clientstate) {
  2686.       if (SendDaemon ("GetTimerList")) {
  2687.          while ((timerentry = AllocRemember (&TimerRememberKey, sizeof (struct TimerEntry), MEMF_ANY|MEMF_CLEAR)) \
  2688.            && (ReceiveDecodedEntry ((UBYTE *) timerentry, sizeof (struct TimerEntry)))) {
  2689.             IsHex (timerentry->timer_address, (long *) &timerentry->timer_adr);
  2690.  
  2691.             if (! *first)
  2692.                *first = timerentry;
  2693.             if (previous)
  2694.                previous->timer_next = timerentry;
  2695.  
  2696.             timercnt++;
  2697.             previous = timerentry;
  2698.          }
  2699.       }
  2700.    } else {
  2701.       if (mp = CreateMsgPort()) {
  2702.          if (tr = CreateIORequest(mp,sizeof(struct timerequest))) {
  2703.             if (!OpenDevice("timer.device",UNIT_MICROHZ,(struct IORequest *)tr,0)) {
  2704.                TimerBase = (struct Library *)tr->tr_node.io_Device;
  2705.                tr->tr_node.io_Command = TR_ADDREQUEST;
  2706.                tr->tr_time.tv_secs = 0;
  2707.                tr->tr_time.tv_micro = 10000;    /* 10ms */
  2708.                Forbid();
  2709.                SendIO((struct IORequest *)tr);
  2710.                for(search = tr;
  2711.                    search->tr_node.io_Message.mn_Node.ln_Pred;
  2712.                    search = (struct timerequest *)search->tr_node.io_Message.mn_Node.ln_Pred);
  2713.  
  2714.                eclk = ReadEClock(&eclock);
  2715.                eclk /= 100;
  2716.  
  2717.                search = (struct timerequest *) search->tr_node.io_Message.mn_Node.ln_Succ;
  2718.                while (search->tr_node.io_Message.mn_Node.ln_Succ != 0) {
  2719.                  if (search!=tr) {
  2720.                      if (!(timerentry = AllocRemember (&TimerRememberKey, sizeof (struct TimerEntry), MEMF_ANY|MEMF_CLEAR))) break;
  2721.                      if (! *first)
  2722.                         *first = timerentry;
  2723.                      if (previous)
  2724.                         previous->timer_next = timerentry;
  2725.  
  2726.                      time = search->tr_time.tv_micro;
  2727.                      if(time > eclock.ev_lo)
  2728.                         time -= eclock.ev_lo;
  2729.                      else
  2730.                         time = 0;
  2731.                      time /= eclk;
  2732.  
  2733.                      sec = search->tr_time.tv_secs + (time/100);
  2734.                      min = sec/60; sec %= 60;
  2735.                      std = min/60; min %= 60;
  2736.  
  2737.                      timerentry->timer_adr = search;
  2738.                      sprintf (timerentry->timer_address, "$%08x", search);
  2739.                      strncpy (timerentry->timer_name, nonetest (((struct Node *)search->tr_node.io_Message.mn_ReplyPort->mp_SigTask)->ln_Name), 27);
  2740.                      sprintf (timerentry->timer_replyport, "$%08x", search->tr_node.io_Message.mn_ReplyPort);
  2741.                      strcpy  (timerentry->timer_unit, "MicroHz");
  2742.                      sprintf (timerentry->timer_timeout, "%ld:%02ld'%02ld.%02ld\"", std, min, sec, time%100);
  2743.                      timercnt++;
  2744.  
  2745.                      previous = timerentry;
  2746.                   }
  2747.                   search = (struct timerequest *) search->tr_node.io_Message.mn_Node.ln_Succ;
  2748.                }
  2749.                Permit();
  2750.                WaitIO((struct IORequest *)tr);
  2751.                CloseDevice((struct IORequest *)tr);
  2752.             }
  2753.             if (!OpenDevice("timer.device",UNIT_VBLANK,(struct IORequest *)tr,0)) {
  2754.                TimerBase = (struct Library *)tr->tr_node.io_Device;
  2755.                tr->tr_node.io_Command = TR_ADDREQUEST;
  2756.                tr->tr_time.tv_secs = 0;
  2757.                tr->tr_time.tv_micro = 20000;    /* 20ms */
  2758.                Forbid();
  2759.                SendIO((struct IORequest *)tr);
  2760.                for(search = tr;
  2761.                    search->tr_node.io_Message.mn_Node.ln_Pred;
  2762.                    search = (struct timerequest *)search->tr_node.io_Message.mn_Node.ln_Pred);
  2763.  
  2764.                eclk = ReadEClock(&eclock);
  2765.  
  2766.                search = (struct timerequest *) search->tr_node.io_Message.mn_Node.ln_Succ;
  2767.                while (search->tr_node.io_Message.mn_Node.ln_Succ != 0) {
  2768.                  if (search!=tr) {
  2769.                      if (!(timerentry = AllocRemember (&TimerRememberKey, sizeof (struct TimerEntry), MEMF_ANY|MEMF_CLEAR))) break;
  2770.                      if (! *first)
  2771.                         *first = timerentry;
  2772.                      if (previous)
  2773.                         previous->timer_next = timerentry;
  2774.  
  2775.                      time = search->tr_time.tv_micro;
  2776.  
  2777.                      if(time > eclock.ev_lo)
  2778.                         time = ((time-eclock.ev_lo)*100)/eclk;
  2779.                      else
  2780.                         time = 0;
  2781.  
  2782.                      sec = search->tr_time.tv_secs + (time/100);
  2783.                      min = sec/60; sec %= 60;
  2784.                      std = min/60; min %= 60;
  2785.  
  2786.                      timerentry->timer_adr = search;
  2787.                      sprintf (timerentry->timer_address, "$%08x", search);
  2788.                      strncpy (timerentry->timer_name, nonetest (((struct Node *)search->tr_node.io_Message.mn_ReplyPort->mp_SigTask)->ln_Name), 27);
  2789.                      sprintf (timerentry->timer_replyport, "$%08x", search->tr_node.io_Message.mn_ReplyPort);
  2790.                      strcpy  (timerentry->timer_unit, "VBlank");
  2791.                      sprintf (timerentry->timer_timeout, "%ld:%02ld'%02ld.%02ld\"", std, min, sec, time%100);
  2792.                      timercnt++;
  2793.  
  2794.                      previous = timerentry;
  2795.                   }
  2796.                   search = (struct timerequest *) search->tr_node.io_Message.mn_Node.ln_Succ;
  2797.                }
  2798.                Permit();
  2799.                WaitIO((struct IORequest *)tr);
  2800.                CloseDevice((struct IORequest *)tr);
  2801.             }
  2802.             DeleteIORequest((struct IORequest *)tr);
  2803.          }
  2804.          DeleteMsgPort(mp);
  2805.       }
  2806.    }
  2807.    return (timercnt);
  2808. }
  2809.  
  2810. void PrintTimer (char *filename) {
  2811.    int   i=1;
  2812.    BPTR  handle;
  2813.    struct TimerEntry *entryp;
  2814.  
  2815.    handle = HandlePrintStart (filename);
  2816.    if ((handle) && (PrintOneLine (handle, "\n  Address  ReplyPort    Time       Unit    Name\n\n"))) {
  2817.       if (! WI_Timer) {
  2818.          i = GetTimer (&entryp);
  2819.       }
  2820.       if (i) {
  2821.          for (i=0;;i++) {
  2822.             if (WI_Timer)
  2823.                DoMethod (timerlist,MUIM_List_GetEntry,i,&entryp);
  2824.             if (!entryp) break;
  2825.  
  2826.             sprintf (tmpstr2, " %ls %ls %13ls %7ls %ls\n", entryp->timer_address, entryp->timer_replyport, entryp->timer_timeout, entryp->timer_unit, entryp->timer_name);
  2827.             if (! (PrintOneLine (handle, tmpstr2)))
  2828.                break;
  2829.  
  2830.             if (! WI_Timer)
  2831.                entryp = entryp->timer_next;
  2832.          }
  2833.       }
  2834.    }
  2835.    HandlePrintStop();
  2836. }
  2837.  
  2838. void ShowTimer (void) {
  2839.    struct TimerEntry *timer;
  2840.  
  2841.    ApplicationSleep();
  2842.    set (timerlist,MUIA_List_Quiet,TRUE);
  2843. //*   set (BT_TimerRemove, MUIA_Disabled, TRUE);
  2844.  
  2845.    FreeTimer();
  2846.    timercnt = GetTimer (&timer);
  2847.  
  2848.    while (timer) {
  2849.       InsertBottomEntry (timerlist, (APTR *) &timer);
  2850.       timer = timer->timer_next;
  2851.    }
  2852.  
  2853.    DoMethod(timerlist,MUIM_List_Sort);
  2854.  
  2855.    SetCountText (timercount, timercnt);
  2856.    AwakeApplication();
  2857.    set (timerlist,MUIA_List_Quiet,FALSE);
  2858. }
  2859.  
  2860. void SendTimerList (void) {
  2861.    struct TimerEntry *timer;
  2862.  
  2863.    FreeTimer();
  2864.    timercnt = GetTimer (&timer);
  2865.  
  2866.    while (timer) {
  2867.       SendEncodedEntry ((UBYTE *) timer, sizeof (struct TimerEntry));
  2868.       timer = timer->timer_next;
  2869.    }
  2870.    FreeTimer();
  2871. }
  2872.  
  2873.  
  2874. /*********************************************************************
  2875.  BEGIN:                        MAIN
  2876. *********************************************************************/
  2877.  
  2878. __asm ULONG main (register __a0 struct WBStartup *msg) {
  2879.    BOOL  RETURN_FLAG = FALSE;
  2880.    ULONG RETURN_CODE = RETURN_OK;
  2881.    struct Library *miamilib = NULL;
  2882.    int   i;
  2883.  
  2884.    if (! init1()) {
  2885.       fail1();
  2886.       return (RETURN_FAIL);
  2887.    }
  2888.  
  2889.    if ((opts.User || opts.Password) && (! opts.Host)) {
  2890.       aprintf ("You didn't specify the HOST!\n");
  2891.       RETURN_CODE = RETURN_FAIL;
  2892.       RETURN_FLAG = TRUE;
  2893.  
  2894.    } else if (opts.Host) {
  2895.       Forbid();
  2896.       if (   FindPort ("AMITCP")
  2897.           ||(miamilib = OpenLibrary("miami.library",0L))) {
  2898.          Permit();
  2899.          if(miamilib) CloseLibrary(miamilib);
  2900.          if (opts.Command) {
  2901.             RETURN_CODE = netshellclient();
  2902.             RETURN_FLAG = TRUE;
  2903.          } else if (! (clientstate = ConnectToServer())) {
  2904.             RETURN_CODE = RETURN_FAIL;
  2905.             RETURN_FLAG = TRUE;
  2906.          }
  2907.       } else {
  2908.          Permit();
  2909.          aprintf ("You have to start AmiTCP 4.0+ first!\n");
  2910.          RETURN_CODE = RETURN_FAIL;
  2911.          RETURN_FLAG = TRUE;
  2912.       }
  2913.  
  2914.    } else if (opts.Command) {
  2915.       shellstate = TRUE;
  2916.       RETURN_CODE = ExecuteCommand (opts.Command);
  2917.       RETURN_FLAG = TRUE;
  2918.  
  2919.    } else {
  2920.       Forbid();
  2921.       if (FindPort ("AMITCP") && isNetCall()) {
  2922.          Permit();
  2923.          RETURN_CODE = netdaemon();
  2924.          RETURN_FLAG = TRUE;
  2925.       } else {
  2926.          Permit();
  2927.       }
  2928.    }
  2929.  
  2930.    if (RETURN_FLAG) {
  2931.       fail1();
  2932.       return (RETURN_CODE);
  2933.    }
  2934.  
  2935.    if (! init2()) {
  2936.       fail();
  2937.       return (RETURN_FAIL);
  2938.    }
  2939.  
  2940.    if ((opts.CpuDisplay) && (! clientstate)) {
  2941.       updatetimestate = (ULONG) *opts.CpuDisplay;
  2942.    }
  2943.  
  2944.    if (opts.SortLibrariesType)
  2945.       libsortstate = *opts.SortLibrariesType;
  2946.    liblist_cmphook_ptr = LibSortList[libsortstate];
  2947.  
  2948.    if (opts.SortDevicesType)
  2949.       devsortstate = *opts.SortDevicesType;
  2950.    devlist_cmphook_ptr = LibSortList[devsortstate];
  2951.  
  2952.    if (opts.SortResourcesType)
  2953.       ressortstate = *opts.SortResourcesType;
  2954.    reslist_cmphook_ptr = LibSortList[ressortstate];
  2955.  
  2956.    if (opts.SortTasksType)
  2957.       tasksortstate = *opts.SortTasksType;
  2958.    tasklist_cmphook_ptr = TaskSortList[tasksortstate];
  2959.  
  2960.    if (opts.SortPortsType)
  2961.       portsortstate = *opts.SortPortsType;
  2962.    portlist_cmphook_ptr = PortSortList[portsortstate];
  2963.  
  2964.    if (opts.SortCommandsType)
  2965.       comsortstate = *opts.SortCommandsType;
  2966.    comlist_cmphook_ptr = ComSortList[comsortstate];
  2967.  
  2968.    if (opts.SortAssignsType)
  2969.       asssortstate = *opts.SortAssignsType;
  2970.    asslist_cmphook_ptr = AssSortList[asssortstate];
  2971.  
  2972.    if (opts.SortLocksType)
  2973.       locksortstate = *opts.SortLocksType;
  2974.    locklist_cmphook_ptr = LockSortList[locksortstate];
  2975.  
  2976.    if (opts.SortCommoditiesType)
  2977.       cxsortstate = *opts.SortCommoditiesType;
  2978.    cxlist_cmphook_ptr = CxSortList[cxsortstate];
  2979.  
  2980.    if (opts.SortClassesType)
  2981.       classsortstate = *opts.SortClassesType;
  2982.    classlist_cmphook_ptr = ClassSortList[classsortstate];
  2983.  
  2984.    if (opts.SortScreenmodeType)
  2985.       smodesortstate = *opts.SortScreenmodeType;
  2986.    smodelist_cmphook_ptr = SModeSortList[smodesortstate];
  2987.  
  2988.    if ((opts.IntervalTime) && (IsReal (opts.IntervalTime))) {
  2989.       if (strlen (opts.IntervalTime) <= 6) {
  2990.          cpuinterval_callfunc (&opts.IntervalTime);
  2991.          strcpy (updatetimetext, opts.IntervalTime);
  2992.       }
  2993.    }
  2994.  
  2995.    if (! GetApplication()) {
  2996.       aprintf ("Failed to create application!\n");
  2997.       fail();
  2998.       return (RETURN_FAIL);
  2999.    }
  3000.  
  3001.    Forbid();
  3002.    if (portname = FindMyARexxPort ("SCOUT")) {
  3003.       myarexxport = FindPort (portname);
  3004.    } else {
  3005.       portname = " < ERROR > ";
  3006.       myarexxport = NULL;
  3007.    }
  3008.  
  3009.    if ((opts.PortName) && (myarexxport)) {
  3010.       portname = opts.PortName;
  3011.       myarexxport->mp_Node.ln_Name = opts.PortName;
  3012.    }
  3013.    Permit();
  3014.  
  3015.    if (opts.Iconified) {
  3016.       set (AP_Scout, MUIA_Application_Iconified, TRUE);
  3017.    }
  3018. /*
  3019. ** Everything's ready, lets launch the application. We will
  3020. ** open the master window now at this old position.
  3021. */
  3022.  
  3023.    DoMethod (AP_Scout,MUIM_Application_Load,MUIV_Application_Load_ENV);
  3024.  
  3025.    SetWindowOpen (WI_Main,NULL,NULL);
  3026.  
  3027. /*
  3028. ** Now the ARexx startup script will be started. Herewith it's
  3029. ** possible to open window at the beginning.
  3030. */
  3031.  
  3032.    if (opts.Startup) {
  3033.       BPTR startuplock;
  3034.       if (startuplock = Lock (opts.Startup, ACCESS_READ)) {
  3035.          UnLock (startuplock);
  3036.          if (! SendStartupMsg ("REXX", opts.Startup, TRUE))
  3037.             aprintf ("Failed to send port 'REXX' scriptname '%ls'!\n", opts.Startup);
  3038.       } else {
  3039.          if (! SendStartupMsg (myarexxport->mp_Node.ln_Name, opts.Startup, FALSE))
  3040.             aprintf ("Failed to send port '%ls' message \"%ls\"!\n", myarexxport->mp_Node.ln_Name, opts.Startup);
  3041.       }
  3042.    }
  3043.  
  3044. /*
  3045. ** This is the main loop. As you can see, it does just nothing.
  3046. ** Everything is handled by MUI, no work for the programmer.
  3047. */
  3048.  
  3049.    {
  3050.       BOOL     running = TRUE;
  3051.       LONG     pos, id; // für MultipleLockSelect
  3052.       ULONG    signal, received;
  3053.       STRPTR   cxhelp;
  3054.       struct   ListEntry      *entryp = 0;
  3055.       struct   Task           *tmptask;
  3056.       struct   Node           *node;
  3057.       ULONG    reid;
  3058.  
  3059.       while (running) {
  3060.          reid = DoMethod(AP_Scout,MUIM_Application_Input,&signal);
  3061.          if(reid==MUIV_Application_ReturnID_Quit)
  3062.            running = FALSE;
  3063.  
  3064.          else if((reid>ID_FIRSTID) && (reid<ID_LASTID)) switch (reid) {
  3065.             case ID_LIBPRINT:
  3066.                PrintLibraries (NULL);
  3067.                break;
  3068.  
  3069.             case ID_LIBRARIES:
  3070.             case ID_LIBUPDATE:
  3071.                LibrariesWindow (TRUE);
  3072.                break;
  3073.  
  3074.             case ID_LIBREMOVE:
  3075.                if (entryp = GetActiveEntry (liblist)) {
  3076.                   if (MyRequest ("Yes|No", "Do you really want to remove\n'%ls'?", ((struct LibEntry *) entryp)->lib_name)) {
  3077.                      MyDoCommand ("RemoveLibrary \"%ls\"", ((struct LibEntry *) entryp)->lib_name);
  3078.                      ShowLibraries ();
  3079.                   }
  3080.                }
  3081.                break;
  3082.  
  3083.             case ID_LIBCLOSE:
  3084.                if (entryp = GetActiveEntry (liblist)) {
  3085.                   int tmpint;
  3086.                   long tmplong;
  3087.  
  3088.                   if ((IsDec (((struct LibEntry *) entryp)->lib_ocnt, &tmplong)) && (tmplong)) {
  3089.                      if (tmpint = MyRequest ("Once|All|Cancel", "Do you really want to close\n '%ls'?", ((struct LibEntry *) entryp)->lib_name)) {
  3090.                         if (tmpint == 1) {
  3091.                            MyDoCommand ("CloseLibrary \"%ls\"", ((struct LibEntry *) entryp)->lib_name);
  3092.                            tmplong--;
  3093.                         } else {
  3094.                            while (tmplong) {
  3095.                               if (! MyDoCommand ("CloseLibrary \"%ls\"", ((struct LibEntry *) entryp)->lib_name)) {
  3096.                                  break;
  3097.                               }
  3098.                               tmplong--;
  3099.                            }
  3100.                         }
  3101.                         sprintf (((struct LibEntry *) entryp)->lib_ocnt, "%3d ", tmplong);
  3102.                         RedrawActiveEntry (liblist);
  3103.                      }
  3104.                   } else {
  3105.                      MyRequest ("Continue", "The OpenCount of \'%ls\' is already zero!", ((struct LibEntry *) entryp)->lib_name);
  3106.                   }
  3107.                }
  3108.                break;
  3109.  
  3110.             case ID_LIBPRIORITY:
  3111.                if (entryp = GetActiveEntry (liblist)) {
  3112.                   LONG tmppri;
  3113.  
  3114.                   if (GetPriority (((struct LibEntry *) entryp)->lib_name, ((struct LibEntry *) entryp)->lib_pri, &tmppri)) {
  3115.                      if (MyDoCommand ("SetPriority LIBRARY \"%ls\" %ld", ((struct LibEntry *) entryp)->lib_name, tmppri)) {
  3116.                         sprintf (((struct LibEntry *) entryp)->lib_pri, "%4d ", tmppri);
  3117.                      }
  3118.                      ShowLibraries ();
  3119.                   }
  3120.                }
  3121.                break;
  3122.  
  3123.             case ID_LIBFUNCTIONS:
  3124.                if (node = HandleNodeDetails (liblist, "library"))
  3125.                   GetLDRFctList ((struct Library *) node,'L');
  3126.                break;
  3127.  
  3128.             case ID_LIBMORE:
  3129.                if (node = HandleNodeDetails (liblist, "library"))
  3130.                   GetLibMore ((struct Library *) node);
  3131.                break;
  3132.  
  3133.             case ID_LIBEXIT:
  3134.                LibrariesWindow (FALSE);
  3135.                break;
  3136.  
  3137.             case ID_LIBLV_ACTIVE:
  3138.                if (entryp = GetActiveEntry (liblist)) {
  3139.                   MySetContents (libtext, "%ls \"%-.30s\"", ((struct LibEntry *) entryp)->lib_address, ((struct LibEntry *) entryp)->lib_name);
  3140.  
  3141.                   set (BT_LibRemove, MUIA_Disabled, FALSE);
  3142.                   set (BT_LibClose, MUIA_Disabled, FALSE);
  3143.                   set (BT_LibPriority, MUIA_Disabled, FALSE);
  3144.  
  3145.                   if (! clientstate) {
  3146.                      set (BT_LibMore, MUIA_Disabled, FALSE);
  3147.                      set (BT_LibFunctions, MUIA_Disabled, FALSE);
  3148.                   }
  3149.                }
  3150.                break;
  3151.  
  3152.             case ID_DEVPRINT:
  3153.                PrintDevices (NULL);
  3154.                break;
  3155.  
  3156.             case ID_DEVICES:
  3157.             case ID_DEVUPDATE:
  3158.                DevicesWindow (TRUE);
  3159.                break;
  3160.  
  3161.             case ID_DEVREMOVE:
  3162.                if (entryp = GetActiveEntry (devlist)) {
  3163.                   if (MyRequest ("Yes|No", "Do you really want to remove\n\'%ls\'?", ((struct LibEntry *) entryp)->lib_name)) {
  3164.                      MyDoCommand ("RemoveDevice \"%ls\"", ((struct LibEntry *) entryp)->lib_name);
  3165.                      ShowDevices ();
  3166.                   }
  3167.                }
  3168.                break;
  3169.  
  3170.             case ID_DEVPRIORITY:
  3171.                if (entryp = GetActiveEntry (devlist)) {
  3172.                   LONG tmppri;
  3173.  
  3174.                   if (GetPriority (((struct LibEntry *) entryp)->lib_name, ((struct LibEntry *) entryp)->lib_pri, &tmppri)) {
  3175.                      if (MyDoCommand ("SetPriority DEVICE \"%ls\" %ld", ((struct LibEntry *) entryp)->lib_name, tmppri)) {
  3176.                         sprintf (((struct LibEntry *) entryp)->lib_pri, "%4d ", tmppri);
  3177.                      }
  3178.                      ShowDevices ();
  3179.                   }
  3180.                }
  3181.                break;
  3182.  
  3183.             case ID_DEVFUNCTIONS:
  3184.                if (node = HandleNodeDetails (devlist, "device"))
  3185.                   GetLDRFctList ((struct Library *) node,'D');
  3186.                break;
  3187.  
  3188.             case ID_DEVMORE:
  3189.                if (node = HandleNodeDetails (devlist, "device"))
  3190.                   GetDevMore ((struct Library *) node);
  3191.                break;
  3192.  
  3193.             case ID_DEVEXIT:
  3194.                DevicesWindow (FALSE);
  3195.                break;
  3196.  
  3197.             case ID_DEVLV_ACTIVE:
  3198.                if (entryp = GetActiveEntry (devlist)) {
  3199.                   MySetContents (devtext, "%ls \"%ls\"", ((struct LibEntry *) entryp)->lib_address, ((struct LibEntry *) entryp)->lib_name);
  3200.  
  3201.                   set (BT_DevRemove, MUIA_Disabled, FALSE);
  3202.                   set (BT_DevPriority, MUIA_Disabled, FALSE);
  3203.  
  3204.                   if (! clientstate) {
  3205.                      set (BT_DevMore, MUIA_Disabled, FALSE);
  3206.                      set (BT_DevFunctions, MUIA_Disabled, FALSE);
  3207.                   }
  3208.                }
  3209.                break;
  3210.  
  3211.             case ID_RESPRINT:
  3212.                PrintResources (NULL);
  3213.                break;
  3214.  
  3215.             case ID_RESOURCES:
  3216.             case ID_RESUPDATE:
  3217.                ResourcesWindow (TRUE);
  3218.                break;
  3219.  
  3220.             case ID_RESREMOVE:
  3221.                if (entryp = GetActiveEntry (reslist)) {
  3222.                   if (MyRequest ("Yes|No", "Do you really want to remove\n\'%ls\'?", ((struct LibEntry *) entryp)->lib_name)) {
  3223.                      MyDoCommand ("RemoveResource \"%ls\"", ((struct LibEntry *) entryp)->lib_name);
  3224.                      ShowResources ();
  3225.                   }
  3226.                }
  3227.                break;
  3228.  
  3229.             case ID_RESPRIORITY:
  3230.                if (entryp = GetActiveEntry (reslist)) {
  3231.                   LONG tmppri;
  3232.  
  3233.                   if (GetPriority (((struct LibEntry *) entryp)->lib_name, ((struct LibEntry *) entryp)->lib_pri, &tmppri)) {
  3234.                      if (MyDoCommand ("SetPriority RESOURCE \"%ls\" %ld", ((struct LibEntry *) entryp)->lib_name, tmppri)) {
  3235.                         sprintf (((struct LibEntry *) entryp)->lib_pri, "%4d ", tmppri);
  3236.                      }
  3237.                      ShowResources ();
  3238.                   }
  3239.                }
  3240.                break;
  3241.  
  3242.             case ID_RESFUNCTIONS:
  3243.                if (node = HandleNodeDetails (reslist, "resource"))
  3244.                   GetLDRFctList ((struct Library *) node,'R');
  3245.                break;
  3246.  
  3247.             case ID_RESMORE:
  3248.                if (node = HandleNodeDetails (reslist, "resource"))
  3249.                   GetResMore ((struct Library *) node);
  3250.                break;
  3251.  
  3252.             case ID_RESEXIT:
  3253.                ResourcesWindow (FALSE);
  3254.                break;
  3255.  
  3256.             case ID_RESLV_ACTIVE:
  3257.                if (entryp = GetActiveEntry (reslist)) {
  3258.                   MySetContents (restext, "%ls \"%ls\"", ((struct LibEntry *) entryp)->lib_address, ((struct LibEntry *) entryp)->lib_name);
  3259.  
  3260.                   set (BT_ResRemove, MUIA_Disabled, FALSE);
  3261.                   set (BT_ResPriority, MUIA_Disabled, FALSE);
  3262.  
  3263.                   if (! clientstate) {
  3264.                      set (BT_ResMore, MUIA_Disabled, FALSE);
  3265.                      set (BT_ResFunctions, MUIA_Disabled, FALSE);
  3266.                   }
  3267.                }
  3268.                break;
  3269.  
  3270.             case ID_TASKPRINT:
  3271.                PrintTasks (NULL);
  3272.                break;
  3273.  
  3274.             case ID_TASKS:
  3275.             case ID_TASKUPDATE:
  3276.                TasksWindow (TRUE);
  3277.                break;
  3278.  
  3279.             case ID_CPUUSAGE:
  3280.                if (! clientstate) {
  3281.                   CheckCPUUsage();
  3282.                }
  3283.                break;
  3284.  
  3285.             case ID_TASKREMOVE:
  3286.                if (entryp = GetActiveEntry (tasklist)) {
  3287.                   if (MyRequest ("Yes|No", "Do you really want to remove\ntask \'%ls\'?", ((struct TaskEntry *) entryp)->ts_name)) {
  3288.                      if (MyDoCommand ("RemoveTask %ls", ((struct TaskEntry *) entryp)->ts_address)) {
  3289.                         RemoveActiveEntry (tasklist);
  3290.                         SetCountText (taskcount, --taskcnt);
  3291.                      } else {
  3292.                         ShowTasks();
  3293.                      }
  3294.                   }
  3295.                }
  3296.                break;
  3297.  
  3298.             case ID_TASKFREEZE:
  3299.                if (entryp = GetActiveEntry (tasklist)) {
  3300.                   if (MyDoCommand ("FreezeTask %ls", ((struct TaskEntry *) entryp)->ts_address)) {
  3301.                      strcpy (((struct TaskEntry *) entryp)->ts_state, "frozen");
  3302.                      RedrawActiveEntry (tasklist);
  3303.                   } else {
  3304.                      ShowTasks();
  3305.                   }
  3306.                }
  3307.                break;
  3308.  
  3309.             case ID_TASKACTIVATE:
  3310.                if (entryp = GetActiveEntry (tasklist)) {
  3311.                   if (MyDoCommand ("ActivateTask %ls", ((struct TaskEntry *) entryp)->ts_address)) {
  3312.                      strcpy (((struct TaskEntry *) entryp)->ts_state, "wait");
  3313.                      RedrawActiveEntry (tasklist);
  3314.                   } else {
  3315.                      ShowTasks();
  3316.                   }
  3317.                }
  3318.                break;
  3319.  
  3320.             case ID_TASKSIGNAL:
  3321.                if (entryp = GetActiveEntry (tasklist)) {
  3322.                   char tmptext[12];
  3323.  
  3324.                   if (GetSignal (((struct TaskEntry *) entryp)->ts_name, ((struct TaskEntry *) entryp)->ts_sigwait, tmptext)) {
  3325.                      if (MyDoCommand ("SignalTask %ls %ls", ((struct TaskEntry *) entryp)->ts_address, tmptext)) {
  3326.                         Delay (25);
  3327.                         RedrawActiveEntry (tasklist);
  3328.                      } else {
  3329.                         ShowTasks();
  3330.                      }
  3331.                   }
  3332.                }
  3333.                break;
  3334.  
  3335.             case ID_TASKBREAK:
  3336.                if (entryp = GetActiveEntry (tasklist)) {
  3337.                   if (MyDoCommand ("BreakTask %ls", ((struct TaskEntry *) entryp)->ts_address)) {
  3338.                      Delay (25);
  3339.                      RedrawActiveEntry (tasklist);
  3340.                   } else {
  3341.                      ShowTasks();
  3342.                   }
  3343.                }
  3344.                break;
  3345.  
  3346.             case ID_TASKPRIORITY:
  3347.                if (entryp = GetActiveEntry (tasklist)) {
  3348.                   long tmppri = 0;
  3349.  
  3350.                   if (GetPriority (((struct TaskEntry *) entryp)->ts_name, ((struct TaskEntry *) entryp)->ts_pri, &tmppri)) {
  3351.                      if (MyDoCommand ("SetTaskPri %ls %ld", ((struct TaskEntry *) entryp)->ts_address, tmppri)) {
  3352.                         sprintf (((struct TaskEntry *) entryp)->ts_pri, "%4d ", tmppri);
  3353.                         RedrawActiveEntry (tasklist);
  3354.                      } else {
  3355.                         ShowTasks();
  3356.                      }
  3357.                   }
  3358.                }
  3359.                break;
  3360.  
  3361.             case ID_TASKMORE:
  3362.                if (entryp = GetActiveEntry (tasklist)) {
  3363.                   Forbid();
  3364.                   if (tmptask = MyFindTask (((struct TaskEntry *) entryp)->ts_address)) {
  3365.                      if (((struct Node *) tmptask)->ln_Type == NT_PROCESS) {
  3366.                         GetProcessMore ((struct Process *) tmptask);
  3367.                      } else {
  3368.                         GetTaskMore ((struct Task *) tmptask);
  3369.                      }
  3370.                      Permit();
  3371.                   } else {
  3372.                      Permit();
  3373.                      MyRequest ("Continue", "Sorry, can't find that %ls!", "task");
  3374.                      ShowTasks();
  3375.                   }
  3376.                }
  3377.                break;
  3378.  
  3379.             case ID_TASKEXIT:
  3380.                TasksWindow (FALSE);
  3381.                break;
  3382.  
  3383.             case ID_TASKLV_ACTIVE:
  3384.                if (entryp = GetActiveEntry (tasklist)) {
  3385.                   MySetContentsHealed (tasktext, "%ls \"%ls\"", ((struct TaskEntry *) entryp)->ts_address, ((struct TaskEntry *) entryp)->ts_name);
  3386.                   set (BT_TaskRemove, MUIA_Disabled, FALSE);
  3387.                   set (BT_TaskFreeze, MUIA_Disabled, FALSE);
  3388.                   set (BT_TaskActivate, MUIA_Disabled, FALSE);
  3389.                   set (BT_TaskPriority, MUIA_Disabled, FALSE);
  3390.                   set (BT_TaskSignal, MUIA_Disabled, FALSE);
  3391.                   set (BT_TaskBreak, MUIA_Disabled, FALSE);
  3392.  
  3393.                   if (! clientstate) {
  3394.                      set (BT_TaskMore, MUIA_Disabled, FALSE);
  3395.                   }
  3396.                }
  3397.                break;
  3398.  
  3399.             case ID_CXPRINT:
  3400.                PrintCx (NULL);
  3401.                break;
  3402.  
  3403.             case ID_COMMODITIES:
  3404.             case ID_CXUPDATE:
  3405.                CxWindow (TRUE);
  3406.                break;
  3407.  
  3408.             case ID_CXREMOVE:
  3409.                if (entryp = GetActiveEntry (cxlist)) {
  3410.                   if (MyRequest ("Yes|No", "Do you really want to remove\ncommodity \'%ls\'?", ((struct CxEntry *) entryp)->cxe_name)) {
  3411.                      if (MyDoCommand ("RemoveCx %ls", ((struct CxEntry *) entryp)->cxe_address)) {
  3412.                         RemoveActiveEntry (cxlist);
  3413.                         SetCountText (cxcount, --cxcnt);
  3414.                      } else {
  3415.                         ShowCx();
  3416.                      }
  3417.                   }
  3418.                }
  3419.                break;
  3420.  
  3421.             case ID_CXPRIORITY:
  3422.                if (entryp = GetActiveEntry (cxlist)) {
  3423.                   long tmppri = 0;
  3424.  
  3425.                   if (GetPriority (((struct CxEntry *) entryp)->cxe_name, ((struct CxEntry *) entryp)->cxe_pri, &tmppri)) {
  3426.                      if (MyDoCommand ("SetCxPri %ls %ld", ((struct CxEntry *) entryp)->cxe_address, tmppri)) {
  3427.                         sprintf (((struct CxEntry *) entryp)->cxe_pri, "%4d ", tmppri);
  3428.                         RedrawActiveEntry (cxlist);
  3429.                      } else {
  3430.                         ShowCx();
  3431.                      }
  3432.                   }
  3433.                }
  3434.                break;
  3435.  
  3436.             case ID_CXMORE:
  3437.                if (entryp = GetActiveEntry (cxlist))
  3438.                   GetCxMore((struct MyCxObj *) ((struct CxEntry *)entryp)->cxe_adr);
  3439.                break;
  3440.  
  3441.             case ID_CXEXIT:
  3442.                CxWindow (FALSE);
  3443.                break;
  3444.  
  3445.             case ID_CXAPPEAR:
  3446.                cxhelp = "Appear";
  3447.                goto cx_setup;
  3448.             case ID_CXDISAPPEAR:
  3449.                cxhelp = "Disappear";
  3450.                goto cx_setup;
  3451.             case ID_CXENABLE:
  3452.                cxhelp = "Enable";
  3453.                goto cx_setup;
  3454.             case ID_CXDISABLE:
  3455.                cxhelp = "Disable";
  3456.                goto cx_setup;
  3457.             case ID_CXKILL:
  3458.                cxhelp = "Kill";
  3459.                goto cx_setup;
  3460.             case ID_CXLISTCHG:
  3461.                cxhelp = "ListChg";
  3462.                goto cx_setup;
  3463.             case ID_CXUNIQUE:
  3464.                cxhelp = "Unique";
  3465. cx_setup:
  3466.                if (entryp = GetActiveEntry (cxlist)) {
  3467.                   MyDoCommand ("Cx%ls \"%ls\"", cxhelp, ((struct CxEntry *) entryp)->cxe_name);
  3468.                   Delay(20);
  3469.                   CxWindow (TRUE);
  3470.                }
  3471.                break;
  3472.  
  3473.             case ID_CXLV_ACTIVE:
  3474.                if (entryp = GetActiveEntry (cxlist)) {
  3475.                   MySetContentsHealed (cxtext, "%ls \"%ls\"", ((struct CxEntry *) entryp)->cxe_address, ((struct CxEntry *) entryp)->cxe_name);
  3476.  
  3477.                   set (BT_CxAppear, MUIA_Disabled, FALSE);
  3478.                   set (BT_CxDisappear, MUIA_Disabled, FALSE);
  3479.                   set (BT_CxEnable, MUIA_Disabled, FALSE);
  3480.                   set (BT_CxDisable, MUIA_Disabled, FALSE);
  3481.                   set (BT_CxKill, MUIA_Disabled, FALSE);
  3482.                   set (BT_CxListChg, MUIA_Disabled, FALSE);
  3483.                   set (BT_CxUnique, MUIA_Disabled, FALSE);
  3484.                   set (BT_CxPriority, MUIA_Disabled, FALSE);
  3485.                   set (BT_CxRemove, MUIA_Disabled, FALSE);
  3486.                   if (! clientstate) {
  3487.                      set (BT_CxMore, MUIA_Disabled, FALSE);
  3488.                   }
  3489.                }
  3490.                break;
  3491.  
  3492.             case ID_CLASSPRINT:
  3493.                PrintClass (NULL);
  3494.                break;
  3495.  
  3496.             case ID_CLASSES:
  3497.             case ID_CLASSUPDATE:
  3498.                ClassWindow (TRUE);
  3499.                break;
  3500.  
  3501.             case ID_CLASSREMOVE:
  3502.                if (entryp = GetActiveEntry (classlist)) {
  3503.                   if (MyRequest ("Yes|No", "Do you really want to remove\nclass \'%ls\'?", ((struct ClassEntry *) entryp)->cse_classname)) {
  3504.                      if (MyDoCommand ("RemoveClass %ls", ((struct ClassEntry *) entryp)->cse_address)) {
  3505.                         RemoveActiveEntry (classlist);
  3506.                         SetCountText (classcount, --classcnt);
  3507.                      } else {
  3508.                         ShowClass();
  3509.                      }
  3510.                   }
  3511.                }
  3512.                break;
  3513.  
  3514.             case ID_CLASSMORE:
  3515.                if (entryp = GetActiveEntry (classlist))
  3516.                   GetClassMore((struct IClass *) ((struct ClassEntry *)entryp)->cse_adr);
  3517.                break;
  3518.  
  3519.             case ID_CLASSEXIT:
  3520.                ClassWindow (FALSE);
  3521.                break;
  3522.  
  3523.             case ID_CLASSLV_ACTIVE:
  3524.                if (entryp = GetActiveEntry (classlist)) {
  3525.                   MySetContentsHealed (classtext, "%ls \"%ls\"", ((struct ClassEntry *) entryp)->cse_address, ((struct ClassEntry *) entryp)->cse_classname);
  3526.  
  3527.                   set (BT_ClassRemove, MUIA_Disabled, FALSE);
  3528.                   if (! clientstate) {
  3529.                      set (BT_ClassMore, MUIA_Disabled, FALSE);
  3530.                   }
  3531.                }
  3532.                break;
  3533.  
  3534.             case ID_SMODEPRINT:
  3535.                PrintSMode (NULL);
  3536.                break;
  3537.  
  3538.             case ID_SCREENMODE:
  3539.             case ID_SMODEUPDATE:
  3540.                SModeWindow (TRUE);
  3541.                break;
  3542.  
  3543.             case ID_SMODEMORE:
  3544.                if (entryp = GetActiveEntry (smodelist))
  3545.                   GetSModeMore((struct SModeEntry *)entryp);
  3546.                break;
  3547.  
  3548.             case ID_SMODEEXIT:
  3549.                SModeWindow (FALSE);
  3550.                break;
  3551.  
  3552.             case ID_SMODELV_ACTIVE:
  3553.                if (entryp = GetActiveEntry (smodelist)) {
  3554.                   MySetContentsHealed (smodetext, "%ls \"%ls\"", ((struct SModeEntry *) entryp)->sme_id, ((struct SModeEntry *) entryp)->sme_name);
  3555.                   if (! clientstate) {
  3556.                      set (BT_SModeMore, MUIA_Disabled, FALSE);
  3557.                   }
  3558.                }
  3559.                break;
  3560.  
  3561.             case ID_LOCKPRINT:
  3562.                PrintLocks (NULL);
  3563.                break;
  3564.  
  3565.             case ID_LOCKS:
  3566.             case ID_LOCKUPDATE:
  3567.                LocksWindow (TRUE);
  3568.                break;
  3569.  
  3570.             case ID_LOCKREMOVE:
  3571.                {
  3572.                int tmpint = 1;
  3573.                id = -1;
  3574.                pos = -42;
  3575.  
  3576.                for (;;) {
  3577.                   DoMethod (locklist,MUIM_List_NextSelected,&id);
  3578.                   if ((id == -1) || (tmpint == 0)) break;
  3579.                   DoMethod (locklist,MUIM_List_GetEntry,id,&entryp);
  3580.                   if (entryp) {
  3581.                      if (tmpint != 2) { // ungleich ALL
  3582.                         tmpint = MyRequest ("Yes|All|No|Abort", "Do you really want to remove lock\n\'%ls\'?", ((struct LockEntry *) entryp)->lock_path);
  3583.                      }
  3584.                      get (locklist,MUIA_List_Active,&pos);
  3585.                      if (pos == id) {
  3586.                         set (locklist,MUIA_List_Active,MUIV_List_Active_Off);
  3587.                      }
  3588.                      if ((tmpint == 1) || (tmpint == 2)) { // YES oder ALL
  3589.                         if (MyDoCommand ("RemoveLock %ls", ((struct LockEntry *) entryp)->lock_address)) {
  3590.                            DoMethod (locklist, MUIM_List_Remove, id);
  3591.                            id -= 1;
  3592.                         }
  3593.                      } else if (tmpint == 3) {
  3594.                         DoMethod (locklist,MUIM_List_Select,id,MUIV_List_Select_Off,NULL);
  3595.                      }
  3596.                   }
  3597.                }
  3598.                }
  3599.                break;
  3600.  
  3601.             case ID_LOCKEXIT:
  3602.                LocksWindow (FALSE);
  3603.                break;
  3604.  
  3605.             case ID_LOCKLV_ACTIVE:
  3606.                if (entryp = GetActiveEntry (locklist)) {
  3607.                   MySetContents (locktext, "%ls \"%ls\"", ((struct LockEntry *) entryp)->lock_address, ((struct LockEntry *) entryp)->lock_path);
  3608.                   set (BT_LockRemove, MUIA_Disabled, FALSE);
  3609.                }
  3610.                break;
  3611.  
  3612.             case ID_PORTPRINT:
  3613.                PrintPorts (NULL);
  3614.                break;
  3615.  
  3616.             case ID_PORTS:
  3617.             case ID_PORTUPDATE:
  3618.                PortsWindow (TRUE);
  3619.                break;
  3620.  
  3621.             case ID_PORTREMOVE:
  3622.                if (entryp = GetActiveEntry (portlist)) {
  3623.                   if (MyRequest ("Yes|No", "Do you really want to remove port\n\'%ls\'?", ((struct PortEntry *) entryp)->pt_name)) {
  3624.                      if (MyDoCommand ("RemovePort %ls", ((struct PortEntry *) entryp)->pt_address)) {
  3625.                         RemoveActiveEntry (portlist);
  3626.                         SetCountText (portcount, --portcnt);
  3627.                      } else {
  3628.                         ShowPorts();
  3629.                      }
  3630.                   }
  3631.                }
  3632.                break;
  3633.  
  3634.             case ID_PORTPRIORITY:
  3635.                if (entryp = GetActiveEntry (portlist)) {
  3636.                   LONG tmppri;
  3637.  
  3638.                   if (GetPriority (((struct PortEntry *) entryp)->pt_name, ((struct PortEntry *) entryp)->pt_pri, &tmppri)) {
  3639.                      if (MyDoCommand ("SetPriority PORT \"%ls\" %ld", ((struct PortEntry *) entryp)->pt_name, tmppri)) {
  3640.                         sprintf (((struct PortEntry *) entryp)->pt_pri, "%4d ", tmppri);
  3641.                      }
  3642.                      ShowPorts();
  3643.                   }
  3644.                }
  3645.                break;
  3646.  
  3647.             case ID_PORTMORE:
  3648.                if (node = HandleNodeDetails (portlist, "port"))
  3649.                   GetPortMore ((struct MsgPort *) node);
  3650.                break;
  3651.  
  3652.             case ID_PORTEXIT:
  3653.                PortsWindow (FALSE);
  3654.                break;
  3655.  
  3656.             case ID_PORTLV_ACTIVE:
  3657.                if (entryp = GetActiveEntry (portlist)) {
  3658.                   MySetContents (porttext, "%ls \"%ls\"", ((struct PortEntry *) entryp)->pt_address, ((struct PortEntry *) entryp)->pt_name);
  3659.                   set (BT_PortRemove, MUIA_Disabled, FALSE);
  3660.                   set (BT_PortPriority, MUIA_Disabled, FALSE);
  3661.  
  3662.                   if (! clientstate) {
  3663.                      set (BT_PortMore, MUIA_Disabled, FALSE);
  3664.                   }
  3665.                }
  3666.                break;
  3667.  
  3668.             case ID_MEMPRINT:
  3669.                PrintMemory (NULL);
  3670.                break;
  3671.  
  3672.             case ID_MEMORY:
  3673.                MemoryWindow (TRUE);
  3674.                break;
  3675.  
  3676.             case ID_MEMPRIORITY:
  3677.                if (entryp = GetActiveEntry (memlist)) {
  3678.                   LONG tmppri;
  3679.  
  3680.                   if (GetPriority (((struct MemoEntry *) entryp)->mem_name, ((struct MemoEntry *) entryp)->mem_pri, &tmppri)) {
  3681.                      if (MyDoCommand ("SetPriority MEMORY \"%ls\" %ld", ((struct MemoEntry *) entryp)->mem_name, tmppri)) {
  3682.                         sprintf (((struct MemoEntry *) entryp)->mem_pri, "%4d ", tmppri);
  3683.                      }
  3684.                      ShowMemory();
  3685.                   }
  3686.                }
  3687.                break;
  3688.  
  3689.             case ID_MEMMORE:
  3690.                if (node = HandleNodeDetails (memlist, "memory"))
  3691.                   GetMemMore ((struct MemHeader *) node);
  3692.                break;
  3693.  
  3694.             case ID_MEMEXIT:
  3695.                MemoryWindow (FALSE);
  3696.                break;
  3697.  
  3698.             case ID_MEMLV_ACTIVE:
  3699.                if (entryp = GetActiveEntry (memlist)) {
  3700.                   MySetContents (memtext, "%ls \"%ls\"", ((struct MemoEntry *) entryp)->mem_address, ((struct MemoEntry *) entryp)->mem_name);
  3701.  
  3702.                   set (BT_MemPriority, MUIA_Disabled, FALSE);
  3703.  
  3704.                   if (! clientstate) {
  3705.                      set (BT_MemMore, MUIA_Disabled, FALSE);
  3706.                   }
  3707.                }
  3708.                break;
  3709.  
  3710.             case ID_MOUNTPRINT:
  3711.                PrintMounts (NULL);
  3712.                break;
  3713.  
  3714.             case ID_MOUNT:
  3715.             case ID_MOUNTUPDATE:
  3716.                MountWindow (TRUE);
  3717.                break;
  3718.  
  3719.             case ID_MOUNTMORE:
  3720.                if (entryp = GetActiveEntry (mountlist)) {
  3721.                   GetMountMore ((struct DeviceNode *) ((struct MountEntry *) entryp)->mt_adr);
  3722.                }
  3723.                break;
  3724.  
  3725.             case ID_MOUNTEXIT:
  3726.                MountWindow (FALSE);
  3727.                break;
  3728.  
  3729.             case ID_MOUNTLV_ACTIVE:
  3730.                if (entryp = GetActiveEntry (mountlist)) {
  3731.                   MySetContents (mounttext, "%ls \"%ls\"", ((struct MountEntry *) entryp)->mt_address, ((struct MountEntry *) entryp)->mt_name);
  3732.  
  3733.                   if (! clientstate) {
  3734.                      set (BT_MountMore, MUIA_Disabled, FALSE);
  3735.                   }
  3736.                }
  3737.                break;
  3738.  
  3739.             case ID_COMPRINT:
  3740.                PrintCommands (NULL);
  3741.                break;
  3742.  
  3743.             case ID_COMMANDS:
  3744.             case ID_COMUPDATE:
  3745.                CommandsWindow (TRUE);
  3746.                break;
  3747.  
  3748.             case ID_COMREMOVE:
  3749.                if ((((struct CommandEntry *) entryp)->cm_adr != NULL) && (entryp = GetActiveEntry (comlist))) {
  3750.                   int tmpint;
  3751.  
  3752.                   if (((struct CommandEntry *) entryp)->cm_uc[0] == 'I') {
  3753.                      MyRequest ("Continue", "Can not remove INTERNAL commands!");
  3754.                   } else if (((struct CommandEntry *) entryp)->cm_uc[0] == 'S') {
  3755.                      MyRequest ("Continue", "Can not remove SYSTEM commands!");
  3756.                   } else if (((struct CommandEntry *) entryp)->cm_uc[0] == 'D') {
  3757.                      MyRequest ("Continue", "Can not remove DISABLED commands!");
  3758.                   } else {
  3759.                      if (MyRequest ("Yes|No", "Do you really want to remove command\n\'%ls\'?", ((struct CommandEntry *) entryp)->cm_name)) {
  3760.                         if (MyDoCommand ("RemoveCommand %ls", ((struct CommandEntry *) entryp)->cm_address)) {
  3761.                            SetCountText (comcount, --comcnt);
  3762.                            RemoveActiveEntry (comlist);
  3763.                            for (tmpint=0;;tmpint++) {
  3764.                               if ((entryp = GetActiveEntry (comlist)) && (((struct CommandEntry *) entryp)->cm_address[0] == ' ')) {
  3765.                                  RemoveActiveEntry (comlist);
  3766.                               } else {
  3767.                                  break;
  3768.                               }
  3769.                            }
  3770.                         }
  3771.                      }
  3772.                   }
  3773.                }
  3774.                break;
  3775.  
  3776.             case ID_COMEXIT:
  3777.                CommandsWindow (FALSE);
  3778.                break;
  3779.  
  3780.             case ID_COMLV_ACTIVE:
  3781.                if (entryp = GetActiveEntry (comlist)) {
  3782.                   if (((struct CommandEntry *) entryp)->cm_adr == NULL) {
  3783.                      MySetContents (comtext, (char *) NULL);
  3784.                   } else {
  3785.                      MySetContents (comtext, "%ls \"%ls\"", ((struct CommandEntry *) entryp)->cm_address, ((struct CommandEntry *) entryp)->cm_name);
  3786.                   }
  3787.                   set (BT_ComRemove, MUIA_Disabled, FALSE);
  3788.                }
  3789.                break;
  3790.  
  3791.             case ID_INTPRINT:
  3792.                PrintInterrupts (NULL);
  3793.                break;
  3794.  
  3795.             case ID_INTERRUPTS:
  3796.             case ID_INTUPDATE:
  3797.                InterruptsWindow (TRUE);
  3798.                break;
  3799.  
  3800.             case ID_INTREMOVE:
  3801.                if (entryp = GetActiveEntry (intlist)) {
  3802.                   if (((struct IntEntry *) entryp)->int_kind[0] == 'H') {
  3803.                      MyRequest ("Resume", "Sorry, I can't remove an\ninterrupt handler!");
  3804.                   } else {
  3805.                      if (MyRequest ("Yes|No", "Do you really want to remove\n\'%ls\'?", ((struct IntEntry *) entryp)->int_name)) {
  3806.                         MyDoCommand ("RemoveInterrupt \"%ls\"", ((struct IntEntry *) entryp)->int_name);
  3807.                         ShowInterrupts();
  3808.                      }
  3809.                   }
  3810.                }
  3811.                break;
  3812.  
  3813.             case ID_INTMORE:
  3814.                if (entryp = GetActiveEntry (intlist)) {
  3815.                   GetIntMore ((struct IntEntry *) entryp);
  3816.                }
  3817.                break;
  3818.  
  3819.             case ID_INTEXIT:
  3820.                InterruptsWindow (FALSE);
  3821.                break;
  3822.  
  3823.             case ID_INTLV_ACTIVE:
  3824.                if (entryp = GetActiveEntry (intlist)) {
  3825.                   MySetContents (inttext, "%ls \"%ls\"", ((struct IntEntry *) entryp)->int_address, ((struct IntEntry *) entryp)->int_name);
  3826.                   set (BT_IntRemove, MUIA_Disabled, FALSE);
  3827.  
  3828.                   if (! clientstate) {
  3829.                      set (BT_IntMore, MUIA_Disabled, FALSE);
  3830.                   }
  3831.                }
  3832.                break;
  3833.  
  3834.             case ID_SEMPRINT:
  3835.                PrintSemaphores (NULL);
  3836.                break;
  3837.  
  3838.             case ID_SEMAPHORES:
  3839.             case ID_SEMUPDATE:
  3840.                SemaphoresWindow (TRUE);
  3841.                break;
  3842.  
  3843.             case ID_SEMOBTAIN:
  3844.                if (entryp = GetActiveEntry (semlist)) {
  3845.                   if (MyRequest ("Yes|No", "Do you really want to obtain semaphore\n\'%ls\'?", ((struct SemEntry *) entryp)->sm_name)) {
  3846.                      if (MyDoCommand ("ObtainSemaphore %ls", ((struct SemEntry *) entryp)->sm_address)) {
  3847.                         ShowSemaphores();
  3848.                      } else {
  3849.                         ShowSemaphores();
  3850.                      }
  3851.                   }
  3852.                }
  3853.                break;
  3854.  
  3855.             case ID_SEMRELEASE:
  3856.                if (entryp = GetActiveEntry (semlist)) {
  3857.                   long  tmplong;
  3858.  
  3859.                   if ((IsDec (((struct SemEntry *) entryp)->sm_nestcount, &tmplong)) && (tmplong)) {
  3860.                      if (MyRequest ("Yes|No", "Do you really want to release semaphore\n\'%ls\'?", ((struct SemEntry *) entryp)->sm_name)) {
  3861.                         MyDoCommand ("ReleaseSemaphore %ls", ((struct SemEntry *) entryp)->sm_address);
  3862.                         ShowSemaphores();
  3863.                      }
  3864.                   } else {
  3865.                      MyRequest ("Continue", "Sorry, the nestcount is already zero!");
  3866.                   }
  3867.                }
  3868.                break;
  3869.  
  3870.             case ID_SEMREMOVE:
  3871.                if (entryp = GetActiveEntry (semlist)) {
  3872.                   long tmplong;
  3873.  
  3874.                   if ((IsDec (((struct SemEntry *) entryp)->sm_nestcount, &tmplong)) && (tmplong)) {
  3875.                      MyRequest ("Continue", "Sorry, the nestcount is not zero!");
  3876.                   } else {
  3877.                      if (MyRequest ("Yes|No", "Do you really want to remove semaphore\n\'%ls\'?", ((struct SemEntry *) entryp)->sm_name)) {
  3878.                         MyDoCommand ("RemoveSemaphore %ls", ((struct SemEntry *) entryp)->sm_address);
  3879.                         ShowSemaphores();
  3880.                      }
  3881.                   }
  3882.                }
  3883.                break;
  3884.  
  3885.             case ID_SEMEXIT:
  3886.                SemaphoresWindow (FALSE);
  3887.                break;
  3888.  
  3889.             case ID_SEMLV_ACTIVE:
  3890.                if (entryp = GetActiveEntry (semlist)) {
  3891.                   MySetContents (semtext, "%ls \"%ls\"", ((struct SemEntry *) entryp)->sm_address, ((struct SemEntry *) entryp)->sm_name);
  3892.                   set (BT_SemObtain, MUIA_Disabled, FALSE);
  3893.                   set (BT_SemRelease, MUIA_Disabled, FALSE);
  3894.                   set (BT_SemRemove, MUIA_Disabled, FALSE);
  3895.                }
  3896.                break;
  3897.  
  3898.             case ID_INPUTPRINT:
  3899.                PrintInputHandlers (NULL);
  3900.                break;
  3901.  
  3902.             case ID_INPUTHANDLER:
  3903.             case ID_INPUTUPDATE:
  3904.                InputHandlerWindow (TRUE);
  3905.                break;
  3906.  
  3907.             case ID_INPUTREMOVE:
  3908.                if (entryp = GetActiveEntry (inputlist)) {
  3909.                   if (MyRequest ("Yes|No", "Do you really want to remove\n\'%ls\'?", ((struct InputEntry *) entryp)->input_name)) {
  3910.                      if (MyDoCommand ("RemoveInputhandler %ls", ((struct InputEntry *) entryp)->input_address)) {
  3911.                         SetCountText (inputcount, --inputcnt);
  3912.                         RemoveActiveEntry (inputlist);
  3913.                      } else {
  3914.                         ShowInputHandler();
  3915.                      }
  3916.                   }
  3917.                }
  3918.                break;
  3919.  
  3920.             case ID_INPUTPRIORITY:
  3921.                if (entryp = GetActiveEntry (inputlist)) {
  3922.                   LONG tmppri;
  3923.  
  3924.                   if (GetPriority (((struct InputEntry *) entryp)->input_name, ((struct InputEntry *) entryp)->input_pri, &tmppri)) {
  3925.                      if (MyDoCommand ("SetPriority INPUTHANDLER \"%ls\" %ld", ((struct InputEntry *) entryp)->input_name, tmppri)) {
  3926.                         sprintf (((struct InputEntry *) entryp)->input_pri, "%4d ", tmppri);
  3927.                      }
  3928.                      ShowInputHandler();
  3929.                   }
  3930.                }
  3931.                break;
  3932.  
  3933.             case ID_INPUTEXIT:
  3934.                InputHandlerWindow (FALSE);
  3935.                break;
  3936.  
  3937.             case ID_INPUTLV_ACTIVE:
  3938.                if (entryp = GetActiveEntry (inputlist)) {
  3939.                   MySetContents (inputtext, "%ls \"%ls\"", ((struct InputEntry *) entryp)->input_address, ((struct InputEntry *) entryp)->input_name);
  3940.                   set (BT_InputRemove, MUIA_Disabled, FALSE);
  3941.                   set (BT_InputPriority, MUIA_Disabled, FALSE);
  3942.                }
  3943.                break;
  3944.  
  3945.             case ID_EXPPRINT:
  3946.                PrintExpansions (NULL);
  3947.                break;
  3948.  
  3949.             case ID_EXPANSIONS:
  3950.                ExpansionsWindow (TRUE);
  3951.                break;
  3952.  
  3953.             case ID_EXPMORE:
  3954.                if (entryp = GetActiveEntry (explist)) {
  3955.                   GetExpansionMore ((struct ConfigDev *) ((struct ExpEntry *) entryp)->exp_adr);
  3956.                }
  3957.                break;
  3958.  
  3959.             case ID_EXPEXIT:
  3960.                ExpansionsWindow (FALSE);
  3961.                break;
  3962.  
  3963.             case ID_EXPLV_ACTIVE:
  3964.                if (entryp = GetActiveEntry (explist)) {
  3965.                   sprintf(tmpstr,"Size=%s Flags=%s ID=%s:%s SN=%s",
  3966.                       ((struct ExpEntry *)entryp)->exp_boardsize,
  3967.                       ((struct ExpEntry *)entryp)->exp_flags,
  3968.                       ((struct ExpEntry *)entryp)->exp_manufacturer,
  3969.                       ((struct ExpEntry *)entryp)->exp_product,
  3970.                       ((struct ExpEntry *)entryp)->exp_serialnumber);
  3971.                   set (exptext,MUIA_Text_Contents,tmpstr);
  3972.  
  3973.                   if (!clientstate) {
  3974.                      set (BT_ExpMore, MUIA_Disabled, FALSE);
  3975.                   }
  3976.                }
  3977.                break;
  3978.  
  3979.             case ID_RESIPRINT:
  3980.                PrintResidents (NULL);
  3981.                break;
  3982.  
  3983.             case ID_RESIDENTS:
  3984.             case ID_RESIUPDATE:
  3985.                ResidentsWindow (TRUE);
  3986.                break;
  3987.  
  3988.             case ID_RESIMORE:
  3989.                if (entryp = GetActiveEntry (resilist)) {
  3990.                   GetResiMore (((struct ResiEntry *) entryp)->rt_adr);
  3991.                }
  3992.                break;
  3993.  
  3994.             case ID_RESIEXIT:
  3995.                ResidentsWindow (FALSE);
  3996.                break;
  3997.  
  3998.             case ID_RESILV_ACTIVE:
  3999.                if (entryp = GetActiveEntry (resilist)) {
  4000.                   MySetContentsHealed (resitext, "%ls \"%ls\"", ((struct ResiEntry *) entryp)->rt_address, ((struct ResiEntry *) entryp)->rt_name);
  4001.  
  4002.                   if (! clientstate) {
  4003.                      set (BT_ResiMore, MUIA_Disabled, FALSE);
  4004.                   }
  4005.                }
  4006.                break;
  4007.  
  4008.             case ID_WINPRINT:
  4009.                PrintWindows (NULL);
  4010.                break;
  4011.  
  4012.             case ID_WINDOWS:
  4013.             case ID_WINUPDATE:
  4014.                WindowsWindow (TRUE);
  4015.                break;
  4016.  
  4017.             case ID_WINCLOSE:
  4018.                if (entryp = GetActiveEntry (winlist)) {
  4019.                   if (((struct WinEntry *) entryp)->wn_type == 'S') {
  4020.                      if ((! clientstate) && (((struct Screen *) ((struct WinEntry *) entryp)->wn_adr)->FirstWindow)) {
  4021.                         if (MyRequest ("Yes|No", "Do you really want to close this\n%ls?", "screen with all its windows")) {
  4022.                            MyDoCommand ("CloseScreen %ls", ((struct WinEntry *) entryp)->wn_address + 2);
  4023.                            ShowWindows();
  4024.                         }
  4025.                      } else {
  4026.                         if (MyRequest ("Yes|No", "Do you really want to close this\n%ls?", "screen")) {
  4027.                            MyDoCommand ("CloseScreen %ls", ((struct WinEntry *) entryp)->wn_address + 2);
  4028.                            ShowWindows();
  4029.                         }
  4030.                      }
  4031.                   } else {
  4032.                      if (MyRequest ("Yes|No", "Do you really want to close this\n%ls?", "window")) {
  4033.                         MyDoCommand ("CloseWindow %ls", ((struct WinEntry *) entryp)->wn_address);
  4034.                         ShowWindows();
  4035.                      }
  4036.                   }
  4037.                }
  4038.                break;
  4039.  
  4040.             case ID_WINTOFRONT:
  4041.                if (entryp = GetActiveEntry (winlist)) {
  4042.                   if (((struct WinEntry *) entryp)->wn_type == 'S') {
  4043.                      MyDoCommand ("PopToFront %ls", ((struct WinEntry *) entryp)->wn_address + 2);
  4044.                   } else {
  4045.                      MyDoCommand ("PopToFront %ls", ((struct WinEntry *) entryp)->wn_address);
  4046.                   }
  4047.                }
  4048.                break;
  4049.  
  4050.             case ID_WINMORE:
  4051.                if (entryp = GetActiveEntry (winlist)) {
  4052.                   if (((struct WinEntry *) entryp)->wn_type == 'W') {
  4053.                      struct Window *tmpwindow;
  4054.  
  4055.                      if (tmpwindow = MyFindWindow (((struct WinEntry *) entryp)->wn_address))
  4056.                         GetWindowMore (tmpwindow);
  4057.                      else
  4058.                         MyRequest ("Continue", "Sorry, can't find that %ls!", "window");
  4059.                   } else {
  4060.                      struct Screen *tmpscreen;
  4061.  
  4062.                      if (tmpscreen = MyFindScreen (((struct WinEntry *) entryp)->wn_address + 2))
  4063.                         GetScreenMore (tmpscreen);
  4064.                      else
  4065.                         MyRequest ("Continue", "Sorry, can't find that %ls!", "screen");
  4066.                   }
  4067.                }
  4068.                break;
  4069.  
  4070.             case ID_WINEXIT:
  4071.                WindowsWindow (FALSE);
  4072.                break;
  4073.  
  4074.             case ID_WINLV_ACTIVE:
  4075.                if (entryp = GetActiveEntry (winlist)) {
  4076.                   if (((struct WinEntry *) entryp)->wn_type == 'S') {
  4077.                      MySetContentsHealed (wintext, "%ls \"%ls\"", ((struct WinEntry *) entryp)->wn_address, ((struct WinEntry *) entryp)->wn_title);
  4078.                   } else {
  4079.                      MySetContentsHealed (wintext, "%ls \"%ls\"", ((struct WinEntry *) entryp)->wn_address, ((struct WinEntry *) entryp)->wn_title);
  4080.                   }
  4081.                   set (BT_WinClose, MUIA_Disabled, FALSE);
  4082.                   set (BT_WinToFront, MUIA_Disabled, FALSE);
  4083.  
  4084.                   if (! clientstate) {
  4085.                      set (BT_WinMore, MUIA_Disabled, FALSE);
  4086.                   }
  4087.                }
  4088.                break;
  4089.  
  4090.             case ID_ALCPRINT:
  4091.                PrintAllocations (NULL);
  4092.                break;
  4093.  
  4094.             case ID_ALLOCATIONS:
  4095.             case ID_ALCUPDATE:
  4096.                AllocationsWindow (TRUE);
  4097.                break;
  4098.  
  4099.             case ID_ALCEXIT:
  4100.                AllocationsWindow (FALSE);
  4101.                break;
  4102.  
  4103.             case ID_ASSPRINT:
  4104.                PrintAssigns (NULL);
  4105.                break;
  4106.  
  4107.             case ID_ASSIGNS:
  4108.             case ID_ASSUPDATE:
  4109.                AssignsWindow (TRUE);
  4110.                break;
  4111.  
  4112.             case ID_ASSREMOVE:
  4113.                if (entryp = GetActiveEntry (asslist)) {
  4114.                   if (((struct AssEntry *) entryp)->ass_path[0] == ' ') {
  4115.                      if (MyRequest ("Yes|No", "Do you really want to remove directory\n\'%ls\' from assign '%ls:\'?", ((struct AssEntry *) entryp)->ass_path +4, ((struct AssEntry *) entryp)->ass_name)) {
  4116.                         if (MyDoCommand ("RemoveAssignList %ls $%lx", ((struct AssEntry *) entryp)->ass_name, ((struct AssEntry *) entryp)->ass_adr)) {
  4117.                            SetCountText (asscount, --asscnt);
  4118.                            RemoveActiveEntry (asslist);
  4119.                         } else {
  4120.                            ShowAssigns();
  4121.                         }
  4122.                      }
  4123.                   } else {
  4124.                      if (MyRequest ("Yes|No", "Do you really want to remove assign\n\'%ls:\'?", ((struct AssEntry *) entryp)->ass_name)) {
  4125.                         if (MyDoCommand ("RemoveAssign %ls", ((struct AssEntry *) entryp)->ass_name)) {
  4126.                            SetCountText (asscount, --asscnt);
  4127.                            RemoveActiveEntry (asslist);
  4128.                            for (i=0;;i++) {
  4129.                               if ((entryp = GetActiveEntry (asslist)) && (((struct AssEntry *) entryp)->ass_path[0] == ' ')) {
  4130.                                  RemoveActiveEntry (asslist);
  4131.                               } else {
  4132.                                  break;
  4133.                               }
  4134.                            }
  4135.                         } else {
  4136.                            ShowAssigns();
  4137.                         }
  4138.                      }
  4139.                   }
  4140.                }
  4141.                break;
  4142.  
  4143.             case ID_ASSEXIT:
  4144.                AssignsWindow (FALSE);
  4145.                break;
  4146.  
  4147.             case ID_ASSLV_ACTIVE:
  4148.                if (entryp = GetActiveEntry (asslist)) {
  4149.                   if (((struct AssEntry *) entryp)->ass_path[0] != ' ') {
  4150.                      MySetContents (asstext, "%ls \"%ls\"", ((struct AssEntry *) entryp)->ass_address, ((struct AssEntry *) entryp)->ass_path);
  4151.                   } else {
  4152.                      MySetContents (asstext, "%ls \"%ls\"", ((struct AssEntry *) entryp)->ass_address, ((struct AssEntry *) entryp)->ass_path +4);
  4153.                   }
  4154.                   set (BT_AssRemove, MUIA_Disabled, FALSE);
  4155.                }
  4156.                break;
  4157.  
  4158.             case ID_FONTPRINT:
  4159.                PrintFonts (NULL);
  4160.                break;
  4161.  
  4162.             case ID_FONTS:
  4163.             case ID_FONTUPDATE:
  4164.                FontsWindow (TRUE);
  4165.                break;
  4166.  
  4167.             case ID_FONTCLOSE:
  4168.                if (entryp = GetActiveEntry (fontlist)) {
  4169.                   int tmpint, tmpint2;
  4170.  
  4171.                   if ((IsDec (((struct FontEntry *) entryp)->font_count, (long *) &tmpint2)) && (tmpint2)) {
  4172.                      if (tmpint = MyRequest ("Once|All|Cancel", "Do you really want to close\n\"%ls\"?", ((struct FontEntry *) entryp)->font_name)) {
  4173.                         if (tmpint == 1) {
  4174.                            MyDoCommand ("CloseFont %ls", ((struct FontEntry *) entryp)->font_address);
  4175.                         } else {
  4176.                            while (tmpint2) {
  4177.                               if (! MyDoCommand ("CloseFont %ls", ((struct FontEntry *) entryp)->font_address)) {
  4178.                                  break;
  4179.                               }
  4180.                               tmpint2--;
  4181.                            }
  4182.                         }
  4183.                         ShowFonts ();
  4184.                      }
  4185.                   } else {
  4186.                      MyRequest ("Continue", "Sorry, the count of accessors is already zero!");
  4187.                   }
  4188.                }
  4189.                break;
  4190.  
  4191.             case ID_FONTREMOVE:
  4192.                if (entryp = GetActiveEntry (fontlist)) {
  4193.                   long  tmplong;
  4194.  
  4195.                   if ((IsDec (((struct FontEntry *) entryp)->font_count, &tmplong)) && (tmplong)) {
  4196.                      MyRequest ("Continue", "Sorry, the count of accessors is not zero!");
  4197.                   } else {
  4198.                      if (MyRequest ("Yes|No", "Do you really want to remove\n\"%ls\" from system?", ((struct FontEntry *) entryp)->font_name)) {
  4199.                         MyDoCommand ("RemoveFont %ls", ((struct FontEntry *) entryp)->font_address);
  4200.                         ShowFonts ();
  4201.                      }
  4202.                   }
  4203.                }
  4204.                break;
  4205.  
  4206.             case ID_FONTEXIT:
  4207.                FontsWindow (FALSE);
  4208.                break;
  4209.  
  4210.             case ID_FONTLV_ACTIVE:
  4211.                if (entryp = GetActiveEntry (fontlist)) {
  4212.                   MySetContents (fonttext, "%ls \"%ls\"", ((struct FontEntry *) entryp)->font_address, ((struct FontEntry *) entryp)->font_name);
  4213.                   set (BT_FontClose, MUIA_Disabled, FALSE);
  4214.                   set (BT_FontRemove, MUIA_Disabled, FALSE);
  4215.                }
  4216.                break;
  4217.  
  4218.             case ID_VECPRINT:
  4219.                PrintVectors (NULL);
  4220.                break;
  4221.  
  4222.             case ID_VECTORS:
  4223.             case ID_VECUPDATE:
  4224.                VectorsWindow (TRUE);
  4225.                break;
  4226.  
  4227.             case ID_VECEXIT:
  4228.                VectorsWindow (FALSE);
  4229.                break;
  4230.  
  4231.             case ID_SYSPRINT:
  4232.                PrintSystem (NULL);
  4233.                break;
  4234.  
  4235.             case ID_SYSTEM:
  4236.             case ID_SYSUPDATE:
  4237.                SystemWindow (TRUE);
  4238.                break;
  4239.  
  4240.             case ID_SYSEXIT:
  4241.                SystemWindow (FALSE);
  4242.                break;
  4243.  
  4244.             case ID_FLUSHDEVS:
  4245.                MyDoCommand ("FLUSHDEVS");
  4246.                break;
  4247.  
  4248.             case ID_FLUSHFONTS:
  4249.                MyDoCommand ("FLUSHFONTS");
  4250.                break;
  4251.  
  4252.             case ID_FLUSHALL:
  4253.                MyDoCommand ("FLUSHALL");
  4254.                break;
  4255.  
  4256.             case ID_FLUSHLIBS:
  4257.                MyDoCommand ("FLUSHLIBS");
  4258.                break;
  4259.  
  4260.             case ID_REMOVEWINFREE:
  4261.                if (WinFree_ToDo) {
  4262.                   RemoveWinFree ();
  4263.                   WinFree_ToDo = NULL;
  4264.                }
  4265.                break;
  4266.  
  4267.             case ID_FLAGWINDOW:
  4268.                if (WinFlag_ToDo) {
  4269.                   GetFlagsMore (WinFlag_ToDo->wf_title2, WinFlag_ToDo->wf_fieldname, WinFlag_ToDo->wf_flags, WinFlag_ToDo->wf_longflag, WinFlag_ToDo->wf_mlongflag, WinFlag_ToDo->wf_fieldtype);
  4270.                   WinFlag_ToDo = NULL;
  4271.                }
  4272.                break;               
  4273.  
  4274.             case ID_CLEARRESET:
  4275.                ClearResetVectors();
  4276.                break;
  4277.  
  4278.             case ID_ABOUT:
  4279.                AboutWindow (TRUE);
  4280.                break;
  4281.  
  4282.             case ID_ABOUTCONTINUE:
  4283.                AboutWindow (FALSE);
  4284.                break;
  4285.  
  4286.             case ID_LIBSORT:
  4287.                                    get (CY_LibSort,MUIA_Cycle_Active,&libsortstate);
  4288.                liblist_cmphook_ptr = LibSortList[libsortstate];
  4289.                ShowLibraries();
  4290.                break;
  4291.  
  4292.             case ID_DEVSORT:
  4293.                                    get (CY_DevSort,MUIA_Cycle_Active,&devsortstate);
  4294.                devlist_cmphook_ptr = LibSortList[devsortstate];
  4295.                ShowDevices();
  4296.                break;
  4297.  
  4298.             case ID_RESSORT:
  4299.                                    get (CY_ResSort,MUIA_Cycle_Active,&ressortstate);
  4300.                reslist_cmphook_ptr = LibSortList[ressortstate];
  4301.                ShowResources();
  4302.                break;
  4303.  
  4304.             case ID_TASKSORT:
  4305.                                    get (CY_TaskSort,MUIA_Cycle_Active,&tasksortstate);
  4306.                tasklist_cmphook_ptr = TaskSortList[tasksortstate];
  4307.                ShowTasks();
  4308.                break;
  4309.  
  4310.             case ID_CXSORT:
  4311.                                    get (CY_CxSort,MUIA_Cycle_Active,&cxsortstate);
  4312.                cxlist_cmphook_ptr = CxSortList[cxsortstate];
  4313.                ShowCx();
  4314.                break;
  4315.  
  4316.             case ID_CLASSSORT:
  4317.                                    get (CY_ClassSort,MUIA_Cycle_Active,&classsortstate);
  4318.                classlist_cmphook_ptr = ClassSortList[classsortstate];
  4319.                ShowClass();
  4320.                break;
  4321.  
  4322.             case ID_SMODESORT:
  4323.                                    get (CY_SModeSort,MUIA_Cycle_Active,&smodesortstate);
  4324.                smodelist_cmphook_ptr = SModeSortList[smodesortstate];
  4325.                ShowSMode();
  4326.                break;
  4327.  
  4328.             case ID_PORTSORT:
  4329.                                    get (CY_PortSort,MUIA_Cycle_Active,&portsortstate);
  4330.                portlist_cmphook_ptr = PortSortList[portsortstate];
  4331.                ShowPorts();
  4332.                break;
  4333.  
  4334.             case ID_COMSORT:
  4335.                                    get (CY_ComSort,MUIA_Cycle_Active,&comsortstate);
  4336.                comlist_cmphook_ptr = ComSortList[comsortstate];
  4337.                ShowCommands();
  4338.                break;
  4339.  
  4340.             case ID_ASSSORT:
  4341.                                    get (CY_AssSort,MUIA_Cycle_Active,&asssortstate);
  4342.                asslist_cmphook_ptr = AssSortList[asssortstate];
  4343.                ShowAssigns();
  4344.                break;
  4345.  
  4346.             case ID_LOCKSORT:
  4347.                                    get (CY_LockSort,MUIA_Cycle_Active,&locksortstate);
  4348.                locklist_cmphook_ptr = LockSortList[locksortstate];
  4349.                ShowLocks();
  4350.                break;
  4351.  
  4352.             case ID_LOWMEMORYPRINT:
  4353.                PrintLowMemory (NULL);
  4354.                break;
  4355.  
  4356.             case ID_LOWMEMORY:
  4357.             case ID_LOWMEMORYUPDATE:
  4358.                LowMemoryWindow (TRUE);
  4359.                break;
  4360.  
  4361. /*
  4362.             case ID_LOWMEMORYCAUSE:
  4363.                if (entryp = GetActiveEntry (lowmemorylist)) {
  4364.                   MyDoCommand ("CauseLowMemory %ls", ((struct LowMemoryEntry *) entryp)->lowmemory_address);
  4365.                }
  4366.                break;
  4367. */
  4368.  
  4369.             case ID_LOWMEMORYREMOVE:
  4370.                if (entryp = GetActiveEntry (lowmemorylist)) {
  4371.                   if (MyRequest ("Yes|No", "Do you really want to remove\n\'%ls\'?", ((struct LowMemoryEntry *) entryp)->lowmemory_name)) {
  4372.                      if (MyDoCommand ("RemoveLowMemory %ls", ((struct LowMemoryEntry *) entryp)->lowmemory_address)) {
  4373.                         SetCountText (lowmemorycount, --lowmemorycnt);
  4374.                         RemoveActiveEntry (lowmemorylist);
  4375.                      } else {
  4376.                         ShowLowMemory();
  4377.                      }
  4378.                   }
  4379.                }
  4380.                break;
  4381.  
  4382.             case ID_LOWMEMORYPRIORITY:
  4383.                if (entryp = GetActiveEntry (lowmemorylist)) {
  4384.                   LONG tmppri;
  4385.  
  4386.                   if (GetPriority (((struct LowMemoryEntry *) entryp)->lowmemory_name, ((struct LowMemoryEntry *) entryp)->lowmemory_pri, &tmppri)) {
  4387.                      if (MyDoCommand ("SetPriority LOWMEMORY \"%ls\" %ld", ((struct LowMemoryEntry *) entryp)->lowmemory_name, tmppri)) {
  4388.                         sprintf (((struct LowMemoryEntry *) entryp)->lowmemory_pri, "%4d ", tmppri);
  4389.                      }
  4390.                      ShowLowMemory();
  4391.                   }
  4392.                }
  4393.                break;
  4394.  
  4395.             case ID_LOWMEMORYEXIT:
  4396.                LowMemoryWindow (FALSE);
  4397.                break;
  4398.  
  4399.             case ID_LOWMEMORYLV_ACTIVE:
  4400.                if (entryp = GetActiveEntry (lowmemorylist)) {
  4401.                   MySetContents (lowmemorytext, "%ls \"%ls\"", ((struct LowMemoryEntry *) entryp)->lowmemory_address, ((struct LowMemoryEntry *) entryp)->lowmemory_name);
  4402. //*                  set (BT_LowMemoryCause, MUIA_Disabled, FALSE);
  4403.                   set (BT_LowMemoryRemove, MUIA_Disabled, FALSE);
  4404.                   set (BT_LowMemoryPriority, MUIA_Disabled, FALSE);
  4405.                }
  4406.                break;
  4407.  
  4408.             case ID_TIMERPRINT:
  4409.                PrintTimer (NULL);
  4410.                break;
  4411.  
  4412.             case ID_TIMER:
  4413.             case ID_TIMERUPDATE:
  4414.                TimerWindow (TRUE);
  4415.                break;
  4416.  
  4417. /*
  4418.             case ID_TIMERREMOVE:
  4419.                if (entryp = GetActiveEntry (timerlist)) {
  4420.                   if (MyRequest ("Yes|No", "Do you really want to remove\n\'%ls\'?", ((struct TimerEntry *) entryp)->timer_name)) {
  4421.                      if (MyDoCommand ("RemoveTimer %ls", ((struct TimerEntry *) entryp)->timer_address)) {
  4422.                         SetCountText (timercount, --timercnt);
  4423.                         RemoveActiveEntry (timerlist);
  4424.                      } else {
  4425.                         ShowTimer();
  4426.                      }
  4427.                   }
  4428.                }
  4429.                break;
  4430. */
  4431.             case ID_TIMEREXIT:
  4432.                TimerWindow (FALSE);
  4433.                break;
  4434.  
  4435.             case ID_TIMERLV_ACTIVE:
  4436.                if (entryp = GetActiveEntry (timerlist)) {
  4437.                   MySetContents (timertext, "%ls \"%ls\"", ((struct TimerEntry *) entryp)->timer_address, ((struct TimerEntry *) entryp)->timer_name);
  4438. //*                  set (BT_TimerRemove, MUIA_Disabled, FALSE);
  4439.                }
  4440.                break;
  4441.  
  4442.             default:
  4443.                break;
  4444.          }
  4445.  
  4446.          if (running && signal) {
  4447.             signal = (signal | 0x0000f000 | 0x01<<TimerSignal);
  4448.             received = Wait (signal);
  4449.          }         
  4450.  
  4451. //         aprintf ("\nSIGNAL: $%08lx  RECEIVED: $%08lx\n", signal, received);
  4452.  
  4453.          if (0x7000 & received) {
  4454.             running = FALSE;
  4455.             aprintf ("***Break\n");
  4456.          }
  4457.  
  4458.          if (0x8000 & received)
  4459.             set (AP_Scout,MUIA_Application_Iconified,FALSE);
  4460.  
  4461.          if (0x01<<TimerSignal & received) {
  4462. //            tmpint++;
  4463.             HandleTimerRequest (TRUE);
  4464.          }
  4465.  
  4466.          signal = (signal & 0xffff0fff & 0x01<<TimerSignal);
  4467.       }
  4468.    }
  4469.  
  4470.    if (opts.Host) {
  4471.       SendDaemon (CMD_END);
  4472.    }
  4473.    fail();
  4474.    return (RETURN_OK);
  4475. }
  4476.  
  4477. /*********************************************************************
  4478.  END:                           MAIN
  4479. *********************************************************************/
  4480.